hi I need select with join in model, example:
SELECT u.id, u.name, p.project_name FROM user AS u JOIN project AS p ON p.user_id = u.id
how do it without phql?
using the relationship of table https://docs.phalcon.io/en/latest/reference/models.html
Hey man
You can use example below :
/** * Returns users which doesn't belong to any organization. * * @return mixed */ public static function getUnassigned() { $query = User::query() ->columns(__NAMESPACE__ . '\User.*') ->leftJoin(__NAMESPACE__ . '\OrganizationUser', __NAMESPACE__ . '\User.id = ou.idUser', 'ou') ->where('ou.idUser IS NULL') ->execute(); if ($query->count()) { return $query; } return false; }
Also you can refer to here https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model_Criteria.html