Setting defaults on the database level makes a lot of sense to prevent the chance of issues arising in the application. Having the configuration for it in the Doctrine annotations makes things easier because you can also automatically generate migrations for it. In MySQL the keyword to use is DEFAULT.
I wanted to have translatable entities in my project. So I used Gedmo translatable [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md] through the doctrine extensions bundle [https://github.com/stof/StofDoctrineExtensionsBundle] for Symfony. When using any kind of entity repository, a listener automatically pulls the right translation
I searched for a easy way to get values that contain a not null in the where clause. That's what I came up with: $repo = $this->getDoctrine()->getRepository('LiplexBundle:User'); $query = $repo ->createQueryBuilder('u') ->where('u.lastOnline > :lastOnline') ->andWhere('u.posts IS NOT NULL') ->setParameter(
I'm persisting a field of type ArrayCollection to a MySQL database which contains only stings. The database field is of type=array in the ORM definition and of type TEXT in the database. /** * @var ArrayCollection * * @ORM\Column(name="currencies", type="array") */ private $currencies; When persisted the field looks like this
I created a complex native query which is populated with quite a few parameters. When executed it didn't deliver the expected result. To send the query to the database I use the following code: $this->getEntityManager() ->getConnection() ->executeQuery($query, $parameter, $types) ->fetchAll(PDO::FETCH_BOTH); I searched