Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 模型模型
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\model;
  15. use think\Db;
  16. use \think\Model;
  17. /**
  18. * 模型
  19. */
  20. class Models extends Model
  21. {
  22. protected $name = 'model';
  23. /**
  24. * 根据模型类型取得数据用于缓存
  25. * @param type $type
  26. * @return type
  27. */
  28. public function getModelAll($type = null, $module = null)
  29. {
  30. $where = array('status' => 1);
  31. if (!is_null($type)) {
  32. $where['type'] = $type;
  33. }
  34. if (!is_null($module)) {
  35. $where['module'] = $module;
  36. }
  37. $data = Db::name('Model')->where($where)->select();
  38. $Cache = array();
  39. foreach ($data as $v) {
  40. $Cache[$v['id']] = $v;
  41. }
  42. return $Cache;
  43. }
  44. /**
  45. * 生成模型缓存,以模型ID为下标的数组
  46. * @return boolean
  47. */
  48. public function model_cache()
  49. {
  50. $data = $this->getModelAll();
  51. cache('Model', $data);
  52. return $data;
  53. }
  54. }