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

how to use joins in find method in models?

how to use joins in find method in models?

You don't use them. You use Model::query or query builder. Find/findFirst is only for finding models in the same class. For joins use other ways or just set relations and use getter for getting related records.


Users::query()
->columns([
'Api\Models\Users.id',
'Api\Models\UserInfo.address'
])
->innerJoin("Api\Models\UserInfo","Api\Models\Users.id = Api\Models\UserInfo.uid")
->execute();

i want to get data of the ids which are present in Users model but not in UserInfo Model...how to write query for this?

Users::query()
->columns([
'Api\Models\Users.id',
'Api\Models\UserInfo.address'
])
->leftJoin("Api\Models\UserInfo","Api\Models\Users.id = Api\Models\UserInfo.uid")
->where('Api\Models\UserInfo.uid IS NULL)
->execute();

How can i get the alias for result obtained..!!