mysql, case sensitive compare through codeigniter

前端 未结 3 1483
梦毁少年i
梦毁少年i 2020-12-22 02:41

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

SELECT * FROM table where column like binary \"abc\";
<
相关标签:
3条回答
  • 2020-12-22 03:07

    I used that and it worked

    $this->db->from("table_name");
    $this->db->where('column_name like binary', $value);
    
    0 讨论(0)
  • 2020-12-22 03:29

    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.

    0 讨论(0)
  • 2020-12-22 03:30

    use:

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

    Regards,
    Pedro

    0 讨论(0)
提交回复
热议问题