Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord - like/or_like - how to pass "_"
#1

[eluser]kezman[/eluser]
Hey everyone!
I have a query:

Code:
SELECT * FROM mytable WHERE myfield LIKE '%text_text%';

I want to use

Code:
$this->db->or_like($key, $value);

But when I pass "_" to $value it is being escaped by CodeIgniter core mysql driver:


system/database/drivers/mysql/mysql/mysql_driver.php
https://github.com/EllisLab/CodeIgniter/...r.php#L326
Code:
// escape LIKE condition wildcards
  if ($like === TRUE)
  {
   $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
  }

Any help will be appreciated!
Thanks in advance!
#2

[eluser]Otemu[/eluser]
Hi,

Try this:

Quote:$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table

http://ellislab.com/codeigniter/user-gui...ecord.html




Theme © iAndrew 2016 - Forum software by © MyBB