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

Can I specify some columns instead of the full columns when finding records?

According to the manual, we can specify the columns, by:

Models::find(array('columns' => 'id, title, content. e.g.'));

But how to specify the columns of the Models with hasManytoMany Relationships?



3.3k
Accepted
answer

You specify which model

Models::find(['columns' => 'YourProject\Models\YourModel.id', YourProject\Models\YourOtherModel.title']);
edited Mar '16

To find related columns use modelsManager imho. This syntax above imho suck.



31.3k

Thanks !!