phalcon模型find的分页写法

动态 1 1224
周先生_1514182293
周先生_1514182293   会员 发布于:16个月前
悬赏:60飞吻
    public function getArticleFromUsers(Array $user = [], int $page = 1, int $nums = 15, int $type = 1)
{
$conditions = "user_id = :user_id: AND status = :status:";
$bind = ['user_id' => $user['id'], 'status' => 1];
if ($type == 1) {
$rows = ForumArticleInfo::find([
"conditions" => $conditions,
"bind" => $bind,
'order' => "id DESC",
'limit' => $nums,
'offset' => ($page - 1) * $nums,
]);
}
$count = ForumArticleInfo::count([
"conditions" => $conditions,
"bind" => $bind
]);
return [
'rows' => !empty($rows) ? $rows : [],
'count' => $count,
'max_page' => (int)ceil($count / $nums)
];
}
回帖

周先生_1514182293 会员

2017-12-25 加入 来自中国

(这个人懒得留下签名)

活跃榜
大家好像都不是很活跃
本周热门
本周暂无热帖