php - Doctrine join 2 tables query issue -
i got 2 entities - product
, group
. connected follows:
/** * products * * @orm\table(name="products") * @orm\entity */ class products { /** * @var \appbundle\entity\group * * @orm\manytoone(targetentity="appbundle\entity\group") * @orm\joincolumns({ * @orm\joincolumn(name="group_id", referencedcolumnname="row_id") * }) */ public $group; }
so each group may contain many products 1 product may connected 1 group. need select 10 groups
products
resulting array should contain more 10 entries there definetely more 1 product per group. tried following:
$qb = $em->createquerybuilder(); $qb->select('g', 'p') ->from('appbundle:group', 'g') ->leftjoin('appbundle:products', 'p', 'with', 'p.group = g.rowid') //->where('p.productnum = g.rowid') ->orderby('g.'.$ordercolumn, $ordertype) ->setfirstresult($start) ->setmaxresults(10); $res = $qb->getquery()->getresult();
but mixed array of groups , products (with group subelement) , of course there less 10 groups in array (but there definetely more 10 groups in db) array of 10 groups products subarray each group. possible? ideas how welcome. thank you.
Comments
Post a Comment