Query MySql in PHP with Symfony -


what difference between

in application 1 / 2:

$qb = $this->createquerybuilder('tu');                  $transunits = $qb->select('tu, te')                     ->leftjoin('tu.translations', 'te')                     ->andwhere($qb->expr()->in('tu.id', $ids))                     ->andwhere($qb->expr()->in('te.locale', $locales))                     ->orderby(sprintf('tu.%s', $sortcolumn), $order)                     ->getquery()                     ->getarrayresult();  ,  $qb = $this->createquerybuilder('tu');                  $transunits = $qb->select('tu, te')                     ->leftjoin('appbundle:translation', 'te')                     ->andwhere($qb->expr()->in('tu.id', $ids))                     ->andwhere($qb->expr()->in('te.locale', $locales))                     ->orderby(sprintf('tu.%s', $sortcolumn), $order)                     ->getquery()                     ->getarrayresult(); 

the functions called exact same parameters.

in second case replace 'tu.translations' 'appbundle:translation' because not recognize 'translations' translations define:

<one-to-many field="translations" target-entity="translationbundle\entity\translation" mapped-by="transunit">             <cascade>                 <cascade-all/>             </cascade> </one-to-many> 

in first case result is: array(13) { ... } , correct format result; in second case wrong format result is: array(70) { ... }

i add in entity class:

/**      * @var \translation      * @orm\onetomany(targetentity="translation", mappedby="transunit")      * @orm\joincolumns({      *   @orm\joincolumn(name="id", referencedcolumnname="trans_unit_id")      * })      */     protected $translations; 

and

/**      * @var \transunit      *      * @orm\manytoone(targetentity="transunit", inversedby="translations")      * @orm\joincolumns({      *   @orm\joincolumn(name="trans_unit_id", referencedcolumnname="id")      * })      */     protected $transunit; 

and work. :)


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -