你好我有插入空值的問題。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