Config.php 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\home\model;
  3. use think\Model;
  4. /**
  5. * 主页导航管理模型
  6. */
  7. class Config extends Model
  8. {
  9. /**
  10. * 主页文字获取
  11. *
  12. * @access public
  13. * @param mixed $field 查询字段
  14. * @param mixed $where 条件
  15. * @param mixed $order 排序
  16. * @return array 返回类型
  17. */
  18. public function getSelect($field, $where=[], $order='id asc')
  19. {
  20. $result = $this->field($field);
  21. if (empty($where) === false) {
  22. foreach ($where as $key => $value) {
  23. if ($key === 0) {
  24. $result = $result->where($value);
  25. } else {
  26. $result = $result->whereOr(function ($query) use ($value) {
  27. $query->where($value);
  28. });
  29. }
  30. }
  31. }
  32. $result = $result->order($order)->select();
  33. return $result;
  34. }//endgetSelect()
  35. }