mysql,区分大小写通过codeigniter比较 [英] mysql, case sensitive compare through codeigniter

查看:123
本文介绍了mysql,区分大小写通过codeigniter比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  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%'


方案

它不是直接通过like()帮助,但你可以这样做:

  $ result = $ this-> db 
- > where('column like binaryabc',NULL,FALSE)
- > get('table')
- > ;结果();

另一种方法是:

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

请注意,我使用的是方法链接,它更快一些。

I wanted to write following query through codeigniter's db helper class, guide me plz

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

I tried

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

but it produces

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

解决方案

It is not supported directly through the like() helper, but you can do this:

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

An alternative method is:

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

Notice I am using method chaining, it's a little quicker and to me is neater.

这篇关于mysql,区分大小写通过codeigniter比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆