mysql, case sensitive compare through codeigniter

前端 未结 3 1490
梦毁少年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: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.

提交回复
热议问题