米粒人生
没看明白为什么写这么多
例:轮播图模型
Focus.php
Focus 中type=0
PC端,type=1
手机端FocusQuery.php 中添加方法
//改自andWhere方法 public function pc(){ if ($this->where === null) { $this->where = ['type'=>0]; } elseif (is_array($this->where) && isset($this->where[0]) && strcasecmp($this->where[0], 'and') === 0) { $this->where[] = ['type'=>0]; } else { $this->where = ['and', $this->where,['type'=>0]]; } return $this; }
Focus.php 添加方法
public static function pc(){ return self::find()->pc(); }
同样能实现
Focus::find()->pc()->all(); Focus::pc()->all();
你没有重载
__staticCall(),Focus::pc()->all()
这一步会报错。另外,你的那么多if()..esle()...
不大好- 米粒人生 2018-07-25 已签到连续签到6天,获得了20个金钱
- 米粒人生 发表了说说前后端分离是大势所趋,对各种视图模板都 不感兴趣....
- 米粒人生 2018-07-24 已签到连续签到5天,获得了20个金钱
- 米粒人生 2018-07-23 已签到连续签到4天,获得了20个金钱
- 米粒人生 2018-07-22 已签到连续签到3天,获得了15个金钱