Query Builder problem

Hello forum,

I have a problem with this query:


$subQuery1 = (new \yii\db\Query())

                ->select(['id_anagrafica', 'sigla_marchio'])

                ->distinct()

                ->from('public.marchi_anagrafica')

                ->where(['not', ['stato' => 'E']])

                ->orderBy(['id_anagrafica' => SORT_ASC, 'sigla_marchio' => SORT_ASC])

                ->all();

        $subQuery2 = (new \yii\db\Query())

                ->select(['ma.id_anagrafica', 'elenco_marchi' => 'string_agg(coalesce(ma.sigla_marchio,\'\'),\',\')'])

                ->from(['ma' => $subQuery1])

                ->groupBy('id_anagrafica')

                ->all();

The error I get is:

strpos() expects parameter 1 to be string, array given (line 793 QueryBuilder.php).

Any suggestions?

Thanks in advance

Solved, I’ve forgot the all() in the first subQuery.