不使用$this->db->query();可以解决这个问题吗?
$data = array();$this->db->like('username', $keywords);
$this->db->or_like('name', $keywords);
$this->db->or_like('contact', $keywords);
$this->db->or_like('email', $keywords);
$this->db->where('status', $status);
$Q = $this->db->get('user', $num, $offset);
出来的SQL语句是:SELECT * FROM (`ci_ccms_user`) WHERE `status` = '0' AND `username` LIKE '%%' OR `name` LIKE '%%' OR `contact` LIKE '%%' OR `email` LIKE '%%' ;
但是我想要的是:SELECT * FROM (`ci_ccms_user`) WHERE `status` = '0' AND (`username` LIKE '%%' OR `name` LIKE '%%' OR `contact` LIKE '%%' OR `email` LIKE '%%' )
或者大家有什么更好的解决方法吗? 直接使用 SQL 有什么不好?
建议直接使用 SQL。 直接使用 SQL 有什么不好?
建议直接使用 SQL。
Hex 发表于 2011-3-25 00:26 http://codeigniter.org.cn/forums/images/common/back.gif
那一般开发中是使用辅助语句,实现不了再使用SQL好,还是直接使用SQL 一般开发不需要写太复杂的 SQL,一般有这种需求是设计问题。
建议复杂SQL用query,简单的用 AR 回复 4# Hex
请教: 什么是AR?? AR就是 Active Record 具体看http://codeigniter.org.cn/user_guide/database/active_record.html 直接用sql吧,AR要不写起来也很复杂 貌似实现不了,不用直接用SQL语句的话 简单查询用ar
条件多的话用sql调用query执行...
页:
[1]