That's what I'm doing:
$entity = new Meta(); $obj = new stdClass(); $obj->foo = 15; $obj->bar = 0; $obj->bor = true; $entity->setObject($obj); $em->persist($entity); $em->flush(); $entity = $entityRepository->find(1); var_dump($entity);
returns:
object(Jo\Model\Entity)[130] protected 'id' => int 1 protected 'user' => null protected 'object' => object(stdClass)[105] public 'foo' => int 15 public 'bar' => int 0 public 'bor' => boolean true $entity->getObject()->bar = 9; var_dump($entity);
returns:
object(Jo\Model\Entity)[130] protected 'id' => int 1 protected 'user' => null protected 'object' => object(stdClass)[105] public 'foo' => int 15 public 'bar' => int 9 public 'bor' => boolean true
!
$em->persist($entity); $em->flush();
But after cleaning, the object is not updated in the database.
Perhaps this is because I am setting a new object from the getObject () method, and it has something to do with links or so, but I donโt understand why the second var_dump () shows the correct values โโto the object.
The recipient is quite simple and simply consists in returning private property.
Any ideas I would like to understand this behavior.
Johnt source share