开发者

mysql, case sensitive compare through codeigniter

开发者 https://www.devze.com 2022-12-24 06:40 出处:网络
I wanted to write following query through codeign开发者_如何学编程iter\'s db helper class, guide me plz

I wanted to write following query through codeign开发者_如何学编程iter'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.


I used that and it worked

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


use:

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

Regards,
Pedro

0

精彩评论

暂无评论...
验证码 换一张
取 消