我想使用KO3 ORM进行一个相关查询,这意味着我想在一个地方有两个条件:
现在我有:
public function get_free(){
return $this->where('static_members_only','=',self::FREE);
}
和我想要的:
public function get_free(){
return $this->where('static_members_only','=',self::FREE) AND (some other conditions)
}
是可能的吗?
谢谢!
and_where()
只是where()
的代理,因此无论您选择使用哪一个都没有区别。所以
ORM::factory('model')
->where('something','=',$something)
->where('something_else','LIKE',$something_else)
->find_all();
将产生如下内容:
SELECT models.*
FROM models
WHERE something = '$something'
AND something_else LIKE '$something_else'
当然,所有的变量都将被转义/准备,所以你不必担心sql注入。
你可以尝试:Kohana的where_open()和where_close()方法?我认为应该这样做。