mysql, case sensitive compare through codeigniter

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

Answers


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.


use:

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

Regards, Pedro


I used that and it worked

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

Need Your Help

GridX clear the sort without making new request

javascript sorting dojo gridx

I am using GridX to display data, but I often change the data store that the GridX is using. I do this by using grid.setStore() and pass in a Dojo JsonStore (this is asynchronous data of course). I...

ASP.NET MVC 4 form cannot logout

c# asp.net-mvc asp.net-mvc-4 partial-views logout

I have been fiddling around with the _Layout and _PartialLayouts of the default MVC 4 templates and suddenly the 'Logout' feature in the '_PartialLogin' doc has stopeed working.