Esempio n. 1
0
 /**
  * 获取分页数据
  *
  * @param int $pager 当前页
  * @param boolean $isExecute 是否执行查询
  * @return ActiveRecord
  */
 public function getByPage($pager = 1, $isExecute = true)
 {
     $result;
     $data = $query = Speech::find()->where(['is_del' => self::STATUS_NORMAL]);
     $maxpager = intval($data->count() / self::PAGE_SIZE + 1);
     if ($pager > $maxpager) {
         $pager = $maxpager;
     }
     $startnum = ($pager - 1) * self::PAGE_SIZE;
     $result = $query->offset($startnum)->limit(self::PAGE_SIZE);
     $result = $result->orderBy(['create_time' => SORT_DESC]);
     if ($isExecute == true) {
         $result = $rows->all();
     }
     return $result;
 }