您好,我在插入空值时遇到问题。
如果我像这样在 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 = 新机型\全部; $all->setAlbumPicture(NULL); $all->setAlbum($getAlbum); $all->setStyle(NULL); $all->setStylePicture(NULL); $this->doctrine->em->persist($all); $this->doctrine->em->flush();
我收到此错误:[Sat Dec 01 14:24:36 2012] [error] [client 84.255.196.168] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在 /home/hosting/easydrobe.com/data 中的 'all (album_id, album_picture_id, style_id, style_picture_id) VALUES (175, NULL, ' at line 1' 附近使用正确的语法/application/libraries/Doctrine/DBAL/Statement.php:131\n堆栈跟踪:\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。
我的模型: http: //pastebin.com/vgq4eWky
有任何想法吗?感谢帮助。