比如定义:
class UserTypeDict extends Model
{
// 定义全局的查询范围
protected static function ba
{
$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条件的存在与否
最佳答案
