根据文档,将第三个参数'none'传递给类似的方法应该可以避免在类似的搜索查询中使用通配符。CodeIgniter Active Record与第三个参数
林这样做,其中$搜索== 'test_username':
$this->db->like('username', $search, 'none');
$this->db->limit(1);
$q = $this->db->get('customers')->row();
var_dump($this->db->last_query());exit;
我希望看到这显示在屏幕上:
SELECT * FROM (`ci_customers`) WHERE `username` LIKE 'test_username' LIMIT 1
但我不是得到这个:
SELECT * FROM (`ci_customers`) WHERE `username` LIKE '%test_username%' LIMIT 1
这似乎是该方法忽略了第三个参数或我做错了什么。有任何想法吗?我可以写出我的查询并使用query()
方法,但我很好奇。
啊,这是它应该的方式(http://ellislab.com/codeigniter/user-guide/database/active_record.html)。你正在运行什么版本的CI? – swatkins
正在运行版本2.1.0 – Rooster