You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

<?php
namespace app\common;
use think\facade\Db;
class GetData{
/**
* 取得無分頁資料
* db:資料表
* param:參數
* @return array list
*/
public static function getList(){
}
/**
* 取得分頁資料
* db:資料表
* param:參數
* @return array list
* list->totle: 總筆數
* list->list: 資料
*/
public static function getPageList($db,$param){
$page = isset($param['page']) ? $param['page'] : 1;
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 10;
$search = isset($param['search']) ? $param['search'] : [];
$where = [
];
$list = Db::name($db)
->where($where)
->order('id', 'desc')
->page($page, $pageSize)
->select()
->toArray();
$total = Db::name($db)
->where($where)
->count();
// foreach($list as $key => $val){
// }
$result = [
'list' => $list,
'total' => $total
];
return $result;
}
}