是否可以为 Model 定义全局条件?
我有 2 个模型:User和Student. 在数据库中,他们俩都在使用表users,但每个学生都设置parent_id为其所有者(设置在同一个表中),而每个用户都parent_id设置为Null.
例如,当我使用
$this->find('all');
在Student模型中,我想强制 Cake 只返回数据库表userswhere 中的那些记录parent_id != Null。
所以问题是 - 我可以在模型中以某种方式定义全局条件吗?像这样的东西:
public $conditions = array('Student.parent_id !=' => Null);