Hello i have problem with inserting null value.
If i test in phpmyadmin like this works great:
INSERT INTO all(id, album_id, album_picture_id, style_id, style_picture_id) VALUES (”,175,null,null,null)
But when i inserting with 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();
i get this error:
[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 have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘all (album_id, album_picture_id, style_id, style_picture_id) VALUES (175, NULL, ‘ at line 1’ in /home/hosting/easydrobe.com/data/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 on line 131
My Model:
http://pastebin.com/vgq4eWky
Any Ideas?
Thanks for help.
Allis a reserved keyword. You should quote it in your entity definition, for example like following: