Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数据库表,其中有一个名为“rstatus”的字段,其值可以是“A”或“X”我如何在模型中为该表设置规则以仅考虑具有 rstatus="A" 的记录?
谢谢
为模型类添加默认范围:
public function defaultScope() { return array ( 'condition' => " rstatus = 'A' " ); }
这是关于defaultScope的更完整的 wiki以及如何有时绕过它。