codeigniter ActiveRecord的where语句问题 [英] codeigniter ActiveRecord where statement issue

查看:306
本文介绍了codeigniter ActiveRecord的where语句问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有这样的说法,我想通过活动记录方式codeigniter

使它

  DELETE FROM表
(COL1 =价值和col2 =值)OR(COL1 =值2和col2 =值);
 

解决方案

codeIgniter活动记录是不切实际的查​​询中混合和的和OR的。

您可能需要手动构造一些查询,例如:沿着线的东西:

  $这个 - > DB-化合物其中(COL1 = $价值和col2 = $值2);
$这个 - > DB-> or_where(COL1 = $值2和col2 = $值);
 

或者,在你的实例,其中仅存在两个特定的列和两个值,以下想法也应该工作:

  $这个 - > DB-> where_in('COL1',数组($值$值2));
$这个 - > DB-> where_in('COL2',数组($值$值2));
$这个 - > DB->('!COL1 = COL2')其中;
 

is have this statement and i want to make it by the Active Records way in codeigniter

DELETE FROM TABLE 
(col1 = value AND col2 = value2 ) OR (col1 = value2 AND col2 = value );

解决方案

CodeIgniter Active Record is impractical for mixing AND's and OR's within a query.

You will likely need to construct some of the query manually, e.g. something along the lines of:

$this->db->where("col1 = $value AND col2 = $value2");
$this->db->or_where("col1 = $value2 AND col2 = $value");

Alternately, in your example where there are only two specific columns and two values, the following idea should also work:

$this->db->where_in('col1', array($value, $value2));
$this->db->where_in('col2', array($value, $value2));
$this->db->where('col1 != col2');

这篇关于codeigniter ActiveRecord的where语句问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆