We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Query builder and all columns select with JOIN

Hello) I have a code:

$items =  \Phalcon\DI::getDefault()->get('modelsManager')->createBuilder()
            ->addFrom('m:Invoices', 'i')
            ->leftJoin('m:users', 'u.id = i.user_id', 'u')
            ->columns('i.id, i.text, i.cost, i.status, DATE_FORMAT(i.date, "%d-%m-%Y") AS dt, u.name')

All works there, but if I want to select all items from first table:

->columns('i.*, u.name')

I get very strange object!!

$items[0]->name - return name from second table $items[0]->text - return error.

How can I receive the same result?

It groups the Invoices object in the alias "i":

foreach ($items as $item) {
      echo $item->name;
      echo $item->i->text;


Thank you. Very strange code, but it works. I have no ideas, how make json from this code :(