"integer", "name" => "varchar", "path" => "varchar", "size" => "varchar", "md5_file" => "varchar", "is_show" => "int", "is_import" => "int", "create_time" => "int", "update_time" => "int" ]; public static function queryPage($params) { $limit = empty($params['limit']) ? Config::get('app.page_size', 20) : (int)$params['limit']; $order = ['id desc']; $list = self::where('is_show',1) ->field('id,name,create_time') ->order($order)->paginate(['list_rows'=>$limit, 'query' => $params]); // halt(self::getLastSql()); return $list; } public static function getNextPrev($id, $cid = null) { $whereP = []; $whereN = []; // $whereP[] = ['status', '=', 1]; // $whereN[] = ['status', '=', 1]; if ($cid) { $whereP[] = ['cid', '=', $cid]; $whereN[] = ['cid', '=', $cid]; } $whereP[] = ['id', ">", $id]; $whereN[] = ['id', "<", $id]; $data_P = self::where($whereP)->order("id desc")->limit(1)->find(); $data_N = self::where($whereN)->order("id desc")->limit(1)->find(); return ['prev' => $data_P, 'next' => $data_N]; } public static function createTimeArchive($limit = 0) { if ($limit == 0) { $timeList = self::distinct(true)->fieldRaw("FROM_UNIXTIME(`create_time`, '%Y-%m') as pubmonth")->order('pubmonth desc')->select(); } else { $timeList = self::distinct(true)->fieldRaw("FROM_UNIXTIME(`create_time`, '%Y-%m') as pubmonth")->order('pubmonth desc')->limit($limit)->select(); } return $timeList; } }