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

Related records not being returned if columns option is specified in Model::find()

Related records will query fine unless I specify specific columns, then it appears that I lose the getRelated() method as well as access to the related records via $model->related_records. Removing the columns definition fixes this problem.

Thoughts?



98.9k

When you set the "columns" parameter, find() returns incomplete objects which does not extend from Phalcon\Mvc\Model thus the getRelated() method is not available. This behavior is mentioned in the docs.

columns: Return specific columns instead of the full columns in the model. When using this option an incomplete object is returned

https://docs.phalcon.io/en/latest/reference/models.html#finding-records

Alright, that makes sense then. Thanks for the response!



75

the ORM very sick