.自定义字符串:
你可以手动的编写子句:
$where = "name='Joe' AND status='boss' OR status='active'";

$this->db->where($where);

不知道大家去验证过没,我测试的时候蛋疼的发现它生成的SQL语句居然是:

SELECT * FROM (`my_table`) WHERE `name='Joe'` AND STATUS='boss' OR STATUS='active'

呃 ,第一个条件居然被视为一个字段名保护起来了 =.=

然后如果在name后加个空格 这样写:

$where = "name ='Joe' AND status='boss' OR status='active'";
 
$this->db->where($where);

得到的SQL是

SELECT * FROM (`my_table`) WHERE `name` ='Joe' AND STATUS='boss' OR STATUS='active'

 posted on 2014-07-31 16:03  whlives  阅读(459)  评论(0编辑  收藏  举报