LinkService.php 768 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * 友链服务
  4. * @author wesmielr
  5. */
  6. namespace app\index\service;
  7. use think\Db;
  8. class LinkService
  9. {
  10. /**
  11. * 获取友链列表
  12. * @param $params 参数
  13. * @param int $num 获取数量
  14. * @param string $field 字段
  15. * @return array
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. * @throws \think\exception\DbException
  19. */
  20. public static function getList($params, $num=6, $field=''){
  21. $field = $field? $field : 'id,name,catname,url,image,target';
  22. return Db::name('link')->where(['status'=> 1])
  23. ->field($field)
  24. ->order('list_order')
  25. ->limit($num)
  26. ->select()
  27. ->toArray();
  28. }
  29. }