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

Add model data to another model with relation

Hi, I have two tables with two models:

  • users [id,username,password,created]
  • posts [id,user_id,message]

and for now, I want when return user data, user posts return with it. I use toArray method for json returning data for example, I want return user model data and post model data insteat of user_id and post_id

Use query builder. You need to do join stuff here.