zsy0228 发表于 2014-10-27 15:44:03

Closer 发表于 2014-10-27 15:30
試試

$this->db->where('uid', 2);


为何要用like,我不模糊查询。。。。

Closer 发表于 2014-10-27 16:16:08

like 我有用第三參數
不過也沒用

你只能用自定義的:
$this->db->query('SELECT * FROM test where (uid=2 or to_uid=2) and status=1')->result();

wlyx 发表于 2014-10-28 10:32:58

$this->db->where('(uid=2');
$this->db->or_where('to_uid=2)');
$this->db->where('status', 1);

以前我也遇到过这个问题,后来就是类似这样处理的;
注意字符串里面有()

Closer 发表于 2014-10-28 10:44:24

wlyx 发表于 2014-10-28 10:32
$this->db->where('(uid=2');
$this->db->or_where('to_uid=2)');
$this->db->where('status', 1);



這樣也行...真是高招

wlyx 发表于 2014-10-28 11:36:12

Closer 发表于 2014-10-28 10:44
這樣也行...真是高招

看完相关处理代码,发现这样也行,哈哈
开始是直接写语句的,后来就改成这样了{:soso_e113:}

一叶倾心 发表于 2015-12-29 17:24:59

wlyx 发表于 2014-10-28 10:32
$this->db->where('(uid=2');
$this->db->or_where('to_uid=2)');
$this->db->where('status', 1);


你的回答解决了我的一个难题,太感谢了
页: 1 [2]
查看完整版本: 求助~~Ci的where复杂语句查询