Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CodeIgniter活动记录,如第3个参数_Codeigniter_Activerecord_Sql Like - Fatal编程技术网

CodeIgniter活动记录,如第3个参数

CodeIgniter活动记录,如第3个参数,codeigniter,activerecord,sql-like,Codeigniter,Activerecord,Sql Like,根据文档,将第三个参数“none”传递给like方法应该可以避免在like搜索查询中使用通配符 我正在这样做,其中$search==“test\u username”: $this->db->like('username', $search, 'none'); $this->db->limit(1); $q = $this->db->get('customers')->row(); var_dump($this->db->last_query

根据文档,将第三个参数“none”传递给like方法应该可以避免在like搜索查询中使用通配符

我正在这样做,其中$search==“test\u 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()
方法,但我很好奇。

看起来2.1.0版本中没有包含“无”的代码。请查看上的第649-692行

然后查看2.1.3版本的第664行:

您需要升级,或者将其添加到
DB\u active\u rec.php
文件中:

...
if ($side == 'none')
{
  $like_statement = $prefix." $k $not LIKE '{$v}'";
}
...

是的,这就是它应该工作的方式()。您正在运行哪个版本的CI?我正在运行版本2.1.0ahhh。接得好。我试图检查核心文件,但找不到正确的文件。谢谢你的澄清!没问题,它在2.1.0文档中,但显然在代码中被省略了。