CodeIgniter Forums
Cutom string in where statement - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Cutom string in where statement (/showthread.php?tid=14941)



Cutom string in where statement - El Forum - 01-21-2009

[eluser]zovar[/eluser]
CI user guide says that we can use custom strings in $this->db->where():

Code:
$where = "name='Joe' AND status='boss' OR status='active'";

$this->db->where($where);

My string is as follows
Code:
$where = " tag='test' OR tag='test1' ";

$this->db->select('id')->from('tags')->where($where);

i get the following error
Code:
A Database Error Occurred
Error Number: 1054

Unknown column 'tag='test'' in 'where clause'

UPDATE `notes` SET `title` = 'title' WHERE `tag='test'` OR tag='test1' AND `id` = '13'

as you can seen the first where statement gets escaped...


Cutom string in where statement - El Forum - 01-21-2009

[eluser]zovar[/eluser]
OK, i think I have figured this out. There is a third parameter in where() which disables the backticks.
where($string, NULL, FALSE)


Cutom string in where statement - El Forum - 08-05-2009

[eluser]Unknown[/eluser]
Thanks! That information helped alot Smile