FAQ Database Discussion Community


doctrine does not hydration when select custom fields

doctrine2,doctrine,doctrine-query
i have tried select fields with doctrine query buidler. $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder->select('au.id, au.firstName') ->from('Api\V1\Entity\AgencyUser', 'au') ->orderBy('au.firstName', 'asc'); $queryBuilder->andWhere('au.agency = :agencyId') ->setParameter('agencyId', $agency->getId()); print_r($queryBuilder->getQuery()->getResult(Query::HYDRATE_OBJECT));exit; result : Array ( [0] => Array ( [id] => 1 [firstName] => agency ) ) why this is an array ? i want to hydrated...

Stuck on a DQL left join query

mysql,doctrine-query
I have two tables: Users <----> Questions They use a ManyToMany relation table to keep track of which user answered which question. Users <----> UsersQuestions <----> Questions Now I need to write a query which fetches all the questions a specific user id has NOT answered yet. The following native...

Doctrine Query Builder Result: not looping correctly

php,symfony2,zend-framework,doctrine2,doctrine-query
I'm not sure if it's that I'm not doing correctly but this is giving me an error: I have 2 Entities: Task and TaskUser. They are connected by a onetoMany. What I want to do is this: foreach($tasks as $task){ echo $task->getTitle; echo $task->getTaskUser()->getFirstName(); } This is my query in...

how to implement join to more than one table on same column in doctrine

doctrine2,doctrine,doctrine-query
My scenario is like this. item_master table item_id (primary key) | item_name -------------------------------------- 1 | Keyboard -------------------------------------- 2 | Mouse -------------------------------------- user_lp_requirement table id1 |item_id | otherColumns1 ----------------------- 1 | 1 | 1 ----------------------- 1 | 2 | 3 ----------------------- item_id is foreign key reference to item_master training_program table id2...

Symfony2.3 Doctrine Query Builder complex query

php,symfony2,doctrine2,doctrine-query
I am looking for the equivalent of this SQL SELECT statement in Doctrine Query Builder: SELECT p.* FROM position p, fonction f WHERE ( (p.id = f.position_id) AND (p.type ='MONO_MEMBRE') AND (f.date_fin IS NOT NULL) ) OR ( p.type='MULTI_MEMBRE' ) I tried this way : function(PositionRepository $er) { return $er->createQueryBuilder('p')...