Multiple entity manager for FOSUserBundle

As you can see, FOSUserBundle can have only one EntityManager. You can see it from the settings orm.xml <service id=”fos_user.entity_manager” factory-service=”doctrine” factory-method=”getManager” class=”Doctrine\ORM\EntityManager” public=”false”> <argument>%fos_user.model_manager_name%</argument> </service> Parameter %fos_user.model_manager_name% specified in settings as model_manager_name fos_user: db_driver: ~ # Required user_class: ~ # Required firewall_name: ~ # Required model_manager_name: ~ So into the constructor comes the instance … Read more

Doctrine2 one-to-one relation auto loads on query

Here is solutions explain with details : https://groups.google.com/forum/#!topic/doctrine-user/fkIaKxifDqc “fetch” in the mapping is a hint, that is, if it is possible Doctrine does that, but if its not possible, obviously it does not. Proxying for lazy-loading is simply not always possible, technically. The situations where its not possible are: 1) one-to-one from inverse to owning … Read more

How to get a Collection in Doctrine2’s query results

The getResult() always returns an array. If you want a collection, you must pass the array that is returned by getResult() to Doctrine’s ArrayCollection e.g. use Doctrine\Common\Collections\ArrayCollection; $result = $this ->getEntityManager() ->createQueryBuilder() ->select(‘p’) ->from(‘…\Player’, ‘p’) ->getQuery() ->getResult() ; $players = new ArrayCollection($result);

request with multiple id Symfony2 Doctrine

You can also get it directly from repository: $em->getRepository(‘YourRepo’)->findById(array(1,2,3,4,5)); Also you can pass parameters in get no tin array, but in simple string glued by commas ?ids=1,2,3,4,56 And after that get it from $request $em->getRepository(‘YourRepo’)->findById(explode(‘,’, $request->get(‘ids’));

How can I use SQL’s YEAR(), MONTH() and DAY() in Doctrine2?

You can add Doctrine extension so you can use the MySql YEAR and MONTH statement by adding this configuration if you’re on Symfony: doctrine: orm: dql: string_functions: MONTH: DoctrineExtensions\Query\Mysql\Month YEAR: DoctrineExtensions\Query\Mysql\Year now you can use the MONTH and YEAR statements in your DQL or querybuilder. Note: The extension supports MySQL, Oracle, PostgreSQL and SQLite.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)