直接在模型中使用标准 SQL

要将 SQL 语法与模型一起使用,将结果转换为正确的实例,你应该直接使用 Phalcon \ Mvc \ Model \ Resultset 类之一:

$users = new \Application\Models\Users();

// bitwise operation on `flag` field
$sql = 'SELECT * FROM phorum.users WHERE
        (15 & (1 << (flag - 1))) > 0  ORDER BY login DESC';

// as a result you will have a Resultset\Simple with Models\Users instances.
$result = new \Phalcon\Mvc\Model\Resultset\Simple(
    null,

    // what model to use for data returned from SQL
    $users,

    // setting result via "read connection" proper for this model.
    $users->getReadConnection()->query($sql) 
);