yuzhigang5460 发表于 2011-5-19 16:58:55

CI的Active Record 类如何处理where语句的问题

本帖最后由 yuzhigang5460 于 2011-5-19 17:00 编辑

where ( c.Name = 'Jack' AND c.Sex='Male' ) OR(m.Tel = '12353' AND m.Mail='mail')
这样的逻辑如何使用CI的where和or_where实现呢?
难道CI做不到?

jeongee 发表于 2011-5-19 17:45:37

回复 yuzhigang5460 的帖子

做不到就别纠结了,直接写sql吧

hinson0 发表于 2011-5-19 18:58:03

yuzhigang5460 发表于 2011-5-19 16:58 static/image/common/back.gif
这样的逻辑如何使用CI的where和or_where实现呢?
难道CI做不到?

$where = '你想要的SQL条件语句';
$this->db->where($where);
就这么简单。其实你的那个where完全可以由CI实现。

longjianghu 发表于 2011-5-19 21:36:18

前面的是m和c是表名吗?

visvoy 发表于 2011-5-20 19:30:30

$this->db->where("( c.Name = 'Jack' AND c.Sex='Male' )","",false)
$this->db->or_where("(m.Tel = '12353' AND m.Mail='mail')","",false)

yuzhigang5460 发表于 2011-5-20 23:29:27

visvoy 发表于 2011-5-20 19:30 static/image/common/back.gif
$this->db->where("( c.Name = 'Jack' AND c.Sex='Male' )","",false)
$this->db->or_where("(m.Tel = '123 ...

竟然居然果然能这么写,谢谢啊。:D
页: [1]
查看完整版本: CI的Active Record 类如何处理where语句的问题