Welcome Guest, Not a member yet? Register   Sign In
Database Class: $this->db->like($field, $value, 'both'); with Wildcards (Underscore '_')
#1

[eluser]Unknown[/eluser]
Hey everyone,


I'm using the Active Record Class to get data from my DB (MySQL).
I've set up a form where a User can submit a search query which will call a Model with this line of code:

Code:
$this->db->like($field, $value, 'both');

Everything works fine, but now, I my client wants to submit Wildcards (especially the underscore) as well.

E.g. if the DB contains:
'aa1aa', 'aa2aa', 'aa3aa', aaXbc'

Code:
$this->db->like($field, 'aa_', 'both');

Should return every four rows. But because of using DB's like() method, the underscore is escaped, so the query is

[code]WHERE field LIKE "


Messages In This Thread
Database Class: $this->db->like($field, $value, 'both'); with Wildcards (Underscore '_') - by El Forum - 02-09-2010, 07:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB