useGlobalScope方法无效

浏览:1707 发布日期:2016/12/10 分类:ThinkPHP5专区
ThinkPHP5中Model的useGlobalScope方法无论参数是true还是false,base方法中定义的全局查询范围都会生效,请问各位大神如何修改该bug

比如定义:
class UserTypeDict extends Model
{
// 定义全局的查询范围
protected static function base(Query $query)
{
$query->where('is_valid', 1);
}
}
UserTypeDict::useGlobalScope(false)->get(2)和UserTypeDict::useGlobalScope(true)->get(2)生成的sql语句都是SELECT * FROM `user_type_dict` WHERE `is_valid` = 1,useGlobalScope方法并没有控制`is_valid` = 1条件的存在与否
最佳答案
评论( 相关
后面还有条评论,点击查看>>