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

Join in model

hi I need select with join in model, example:

    u.id, u.name, p.project_name
    user AS u
    JOIN project AS p ON p.user_id = u.id

how do it without phql?

edited Mar '15

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')

    if ($query->count()) {
        return $query;

    return false;

Also you can refer to here http://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model_Criteria.html