I am trying to make something very simple .. but I am mistaken and I do not know what the problem is. I'm just trying to insert a new item into the database using Doctrine 2:
$favouriteBook = new UserFavouriteBook; $favouriteBook->user_id = 5; $favouriteBook->book_id = 8; $favouriteBook->created_at = new DateTime("now"); $this->_em->persist($favouriteBook); $this->_em->flush();
As you can see .. very simple, but give me the following error:
Error: Message: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null
Obviosly, if I create a "dump" before "persist" and "flush" from $ favoriteBook, everything looks right.
This is my favoriteBook object:
private $user_id; private $book_id; private $book; private $user; private $created_at; public function __get($property) { return $this->$property; } public function __set($property, $value) { $this->$property = $value; }
Can anyone understand what the problem is? .. I donβt know what else to try .. Thanks
source share