直接在模型中使用標準 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) 
);