你好我有插入空值的问题。Doctrine2插入NULL值错误
如果我在phpMyAdmin测试这样的伟大工程: INSERT INTO all
(id
,album_id
,album_picture_id
,style_id
,style_picture_id
)VALUES( '',175,NULL,NULL,NULL)
但是,当我插入与Doctrine2:
$getAlbum = $this->doctrine->em->getRepository('models\Album')->findOneBy(array('id'=>175)); $all = new models\All; $all->setAlbumPicture(NULL); $all->setAlbum($getAlbum); $all->setStyle(NULL); $all->setStylePicture(NULL); $this->doctrine->em->persist($all); $this->doctrine->em->flush();
我得到这个错误: [星期六12月1 14时24分36秒2012] [错误] [客户84.255.196.168] PHP致命错误:未捕获的异常 'PDOException' 有消息“SQLSTATE [ 42000]:语法错误或a访问违例:1064您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册,以便在'all(album_id,album_picture_id,style_id,style_picture_id)附近使用正确的语法VALUES(175,NULL,位于/home/hosting/easydrobe.com/data的'第1行' /application/libraries/Doctrine/DBAL/Statement.php:131\nStack trace:\ n#0 /home/hosting/easydrobe.com/data/application/libraries/Doctrine/DBAL/Statement.php(131):PDOStatement- > execute(NULL)\ n#1 /home/hosting/easydrobe.com/data/application/libraries/Doctrine/ORM/Persisters/BasicEntityPersister.php(239):Doctrine \ DBAL \ Statement-> execute()\ n# 2 /home/hosting/easydrobe.com/data/application/libraries/Doctrine/ORM/UnitOfWork.php(896):Doctrine \ ORM \ Persisters \ BasicEntityPersister-> executeInserts()\ n#3/home/hosting/easydrobe。 com/data/application/libraries/Doctrine/ORM/UnitOfWork.php(304):Doctrine \ ORM \ UnitOfWork-> executeInserts(Object(Doctrine \ ORM \ Mapping \ ClassM in /home/hosting/easydrobe.com/data/application /libraries/Doctrine/DBAL/Statement.php在线131
我的模型: http://pastebin.com/vgq4eWky
什么想法? 感谢您的帮助。
谢谢你,现在工作。 – Alen