| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * 信息分类服务
- * @author wesmielr
- */
- namespace app\index\service;
- use think\Db;
- class NewsCategoryService
- {
- /**
- * 获取资讯主分类
- * @param int $num 条数
- * @return array|\PDOStatement|string|\think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getCates($num=30){
- return Db::name('news_category')
- ->where('parent_id',0)
- ->field('id,catname,enname')
- ->order('list_order')
- ->limit($num)
- ->select();
- }
- /**
- * 获取分类数据
- * @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();
- }
- }
|