Help creating union and using withQuery

I’m trying to follow the guide to use a union query with a withQuery

    $dispatchers = (new \yii\db\Query())
        ->select(['DispatcherId', 'DispatcherName'])
        ->withQuery( $queryProjectsDispatchers->union($queryLegsDispatchers), 't1', true)
        ->orderBy(['DispatcherName' => SORT_ASC]);

but keep getting the following error

Calling unknown method: yii\db\Query::withQuery()

which highlights the ->withQuery line of code.

What am I doing wrong?

Most probably you are using an older version of Yii 2.

1 Like

Thank you. I came to that conclusion as well last night.

I have a follow-up question regarding upgrading. On my dev machine, I should be able to use composer to perform the update, fingers crossed that works flawlessly. But what about my production system with which I have FTP access? What folder(s) do I have to update exactly?

Also, are there any concerns with updating or should things continue to work as they previously did, but get all the various enhancements of the newer version(s)?


1 Like

Thank you for the link, greatly appreciated. For whatever reason I couldn’t find such information using Google.