如何在PHP的idorm SQL查询中使用OR?
我正在使用idiorm()开发一个从数据库中获取数据的应用程序 以下是我的代码:如何在PHP的idorm SQL查询中使用OR?,php,mysql,idiorm,Php,Mysql,Idiorm,我正在使用idiorm()开发一个从数据库中获取数据的应用程序 以下是我的代码: $messages = Model::factory('Messages')->where('from_user_id','1')->find_many(); 我想包括一个or语句,where->('to\u user\u id','1') 我怎样才能在Idiorm查询中将其作为OR语句?我不熟悉Idiorm,但看看您应该能够使用where\u raw构建您自己的where子句: /**
$messages = Model::factory('Messages')->where('from_user_id','1')->find_many();
我想包括一个or语句,where->('to\u user\u id','1')
我怎样才能在Idiorm查询中将其作为OR语句?我不熟悉Idiorm,但看看您应该能够使用
where\u raw
构建您自己的where子句:
/**
* Add a raw WHERE clause to the query. The clause should
* contain question mark placeholders, which will be bound
* to the parameters supplied in the second argument.
*/
public function where_raw($clause, $parameters=array()) {
return $this->_add_where($clause, $parameters);
}
类似于
->where_raw('from_user_id=?或to_user_id=?',array(1,1))
这看起来像是手册告诉您如何处理OR条件
$messages = Model::factory('Messages')
->where_any_is(
array(
array('from_user_id' => 1),
array('to_user_id' => 1)
)
)
->find_many();
我敢向你推荐RT“芳香”M
我知道这是最后的选择,但还是试一试吧。我花了3分钟才找到,你花了多长时间写这个问题?