我想通过codeigniter的db helper类编写以下查询,引导我plz
SELECT * FROM table where column like binary "abc";
Run Code Online (Sandbox Code Playgroud)
我试过了
$this->db->select("*");
$this->db->from("table");
$this->db->like("column","binary abc");
$this->db->get();
Run Code Online (Sandbox Code Playgroud)
但它产生了
SELECT * FROM table WHERE column like '%binary abc%'
Run Code Online (Sandbox Code Playgroud)
Phi*_*eon 12
它不是通过like()帮助程序直接支持,但您可以这样做:
$result = $this->db
->where('column like binary "abc"', NULL, FALSE)
->get('table')
->result();
Run Code Online (Sandbox Code Playgroud)
另一种方法是:
$result = $this->db
->where('LOWER(column)', strtolower($foo), FALSE)
->get('table')
->result();
Run Code Online (Sandbox Code Playgroud)
注意我使用方法链接,它更快一些,对我来说更整洁.
归档时间: |
|
查看次数: |
10707 次 |
最近记录: |