Closed mschrading closed 5 years ago
Hi,
You need to set the hydrate
option to Query::HYDRATE_ARRAY
:
->createAdapter(ORMAdapter::class, [
'hydrate' => \Doctrine\ORM\Query::HYDRATE_ARRAY,
'entity' => Meldung::class,
'query' => function (QueryBuilder $builder) {
$builder
->distinct()
->select('m, b, v, m.lfd')
->from(Meldung::class, 'm')
->leftJoin('m.lastUser', 'b')
->leftJoin('m.process', 'v')
->leftJoin('m.messageType', 't');
}
]
I think removing the distinct() and not selecting the m.lfd from your query would do the trick.
Why would you select it seperatly anyway, it's part of the entity you were selecting in the first place and since you are using the ORMAdapter you're actually expect it to return one of your objects: Meldung
Thank you friends I'll try that out
I've checked that out and I get only one result set array[0]! So how can I iterate through all results? Thank you for any help
By setting 'hydrate' => \Doctrine\ORM\Query::HYDRATE_ARRAY, I'll get an array with one set of data which will be iterated trough all result sets. On using goupedBy I'll get all resuzkltssets in an array which I have to loop through but how to use this in a Omines datatable? Thank you for any hint
On building a data collection in omines datatable in symfony 4.2 and using QueryBuilder I have this
function (QueryBuilder $builder) { $builder ->distinct() ->select('m, b, v, m.lfd') ->from(Meldung::class, 'm') ->leftJoin('m.lastUser', 'b') ->leftJoin('m.process', 'v') ->leftJoin('m.messageType', 't'); }
I got this error message from symfony:Cannot read property "id" from an array. Maybe you intended to write the property path as "[id]" instead.
This error message comes when I add m.lfd (or some other specific field) in the select list
I don't know how to handle this.