PhalconPHP 绑定参数和命令

PhalconPHP bind params and oerder by

这是我试过的代码

$conditions = "category = :id: AND status = :status: ORDER BY :order: LIMIT 3";

$parameters = array(
    "id" => $cat_id,
    "status" => 1,
    "order" => "title ASC",
);

$posts = Posts::find(array(
    $conditions,
    "bind" => $parameters
));

一切正常,除了 order by。你能帮我找出在 PhalconPHP 中使用 order by 的正确方法吗?

"bind" 和 "order" 是 separate parameters:

$conditions = "category = :id: AND status = :status:";

$parameters = array(
    "id" => $cat_id,
    "status" => 1,
);

$posts = Posts::find(array(
    "conditions" => $conditions,
    "bind" => $parameters,
    "order" => "title ASC",
    "limit" => 3
));

这是干净可靠的方法 - 这样您的条件就只有严格的 条件。您可以根据请求参数更改 limit/order 而无需触及条件字符串。