用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3934|回复: 5
收起左侧

[已解决] CI的Active Record 类如何处理where语句的问题

[复制链接]
发表于 2011-5-19 16:58:55 | 显示全部楼层 |阅读模式
本帖最后由 yuzhigang5460 于 2011-5-19 17:00 编辑
SQL复制代码
WHERE ( c.Name = 'Jack' AND c.Sex='Male' ) OR  (m.Tel = '12353' AND m.Mail='mail')
复制代码

这样的逻辑如何使用CI的where和or_where实现呢?
难道CI做不到?
发表于 2011-5-19 17:45:37 | 显示全部楼层
回复 yuzhigang5460 的帖子

做不到就别纠结了,直接写sql吧
发表于 2011-5-19 18:58:03 | 显示全部楼层
yuzhigang5460 发表于 2011-5-19 16:58
这样的逻辑如何使用CI的where和or_where实现呢?
难道CI做不到?

$where = '你想要的SQL条件语句';
$this->db->where($where);
就这么简单。其实你的那个where完全可以由CI实现。
发表于 2011-5-19 21:36:18 | 显示全部楼层
前面的是m和c是表名吗?
发表于 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)
 楼主| 发表于 2011-5-20 23:29:27 | 显示全部楼层
visvoy 发表于 2011-5-20 19:30
$this->db->where("( c.Name = 'Jack' AND c.Sex='Male' )","",false)
$this->db->or_where("(m.Tel = '123 ...

竟然居然果然能这么写,谢谢啊。

本版积分规则