| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- /**
- * 友链服务
- * @author wesmielr
- */
- namespace app\index\service;
- use think\Db;
- class LinkService
- {
- /**
- * 获取友链列表
- * @param $params 参数
- * @param int $num 获取数量
- * @param string $field 字段
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getList($params, $num=6, $field=''){
- $field = $field? $field : 'id,name,catname,url,image,target';
- return Db::name('link')->where(['status'=> 1])
- ->where(function($query) use($params){
- $catname = isset($params['catname'])? : '';
- if($catname){
- $query->where('catname', $catname);
- }
- })
- ->field($field)
- ->order('list_order')
- ->limit($num)
- ->select()
- ->toArray();
- }
- }
|