mysql,通过codeigniter进行区分大小写的比较

时间:2010-03-29 13:16:20

标签: codeigniter

我想通过codeigniter的db helper类编写以下查询,引导我plz

SELECT * FROM table where column like binary "abc";

我试过

$this->db->select("*");
$this->db->from("table");
$this->db->like("column","binary abc");
$this->db->get();

但它会产生

SELECT * FROM table WHERE column like '%binary abc%'

3 个答案:

答案 0 :(得分:11)

不直接通过like()帮助程序支持,但您可以这样做:

$result = $this->db
    ->where('column like binary "abc"', NULL, FALSE)
    ->get('table')
    ->result();

另一种方法是:

$result = $this->db
    ->where('LOWER(column)', strtolower($foo), FALSE)
    ->get('table')
    ->result();

注意我使用方法链接,它更快一些,对我来说更整洁。

答案 1 :(得分:0)

使用:

$ this-> db-> where('column like binary“abc”');
$结果= $这 - > DB->获得( '表');

的问候,
佩德罗

答案 2 :(得分:0)

我用过它并且有效

$this->db->from("table_name");
$this->db->where('column_name like binary', $value);
相关问题