where('parent_id',0) ->field('id,catname,enname') ->order('list_order') ->limit($num) ->select(); $dataList = $dataList ? $dataList->toArray() : []; if ($dataList) { RedisService::set($cacheKey, $dataList, 3 * 3600); } return $dataList; } /** * 获取分类数据 * @param $ids * @return array|\PDOStatement|string|\think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getCatesListByIds($ids, $num=99999){ return Db::name('news_category') ->where('parent_id',0) ->whereIn('id',$ids) ->field('id,catname,enname') ->order('list_order') ->limit($num) ->select(); } }