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

usually query on model

how to change this "SELECT a., a.name as name_cat, r., r.name as name_al FROM gallery_category a LEFT JOIN gallery r ON a.default_image = r.id"

to instead use a model?



33.8k

Creating the models => https://docs.phalcon.io/es/latest/reference/models.html#creating-models Setting the relationships => https://docs.phalcon.io/es/latest/reference/models.html#relationships-between-models Finding records => https://docs.phalcon.io/es/latest/reference/models.html#finding-records

When you set the relationships and search a record, the record will have a property with the name of the associated table, so you can access it's properties from the original record.



8.5k

I've tried it but to no avail did not show me the results in Table gallery



33.8k

You don't show the results in the model; you return then from the model to the controller, and there set up for the view.