We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHQL

Hi!

how to get a similar result on PHQL, converting $robots = Data :: find()?

$robots = $connection->query($sql)->fetchAll();

You mean this?

// Models
$all = News::find();

// QueryBuilder
$all = $this->modelsManager->createBuilder()
    ->from('Models\News')
    ->getQuery()->execute();

Both will return same results. Please note that if you use ->columns() on the QueryBuilder it will return simple object, not full News object.



3.7k
edited Aug '16

I have the ultimate goal of such a reduction - recursive function build a hierarchy of database via PHP. In the case of the find () passing an array stops on the last item in the first nesting level and are not passed on the levels below . Something I have done wrong in the case of an object , but an array of all turned out perfectly .

Show us any sample of your code. Im guessing that you are iterating same object in array ? Then in nested loops you will change a pointer of resultset, that's why you have problem. You would need to work on plain array toArray method. Or clone resultset for each new loop.