Dex*_*url 1 php activerecord codeigniter
使用like进行非常简单的搜索,并且可以省略选项,但是我发现like语句正在使查询忽略where语句
$this->db->like('LOWER(location) OR LOWER(name)', strtolower($term));
$this->db->where('stage', 1);
$this->db->order_by("name", "asc");
$query = $this->db->get($this->user_table);
return $query->result();
Run Code Online (Sandbox Code Playgroud)
使用$ term ="dublin"生成上述内容的示例;
SELECT * FROM (`users`) WHERE `stage` = 1 AND LOWER(location) OR LOWER(name) LIKE '%dublin%' ORDER BY `name` asc"
Run Code Online (Sandbox Code Playgroud)
它仍然返回'stage'不等于1的行.
有任何想法吗?谢谢!
$term = strtolower($term);
$this->db->where("(LOWER(location) LIKE '%{$term}%' OR LOWER(name) LIKE '%{$term}%')");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6084 次 |
| 最近记录: |