Saturday, 24 August 2013

Getting mysql syntax error using codeigniter LIKE active record

Getting mysql syntax error using codeigniter LIKE active record

this is my code
return $this->db
->select('organization')
->like('title',$this->db->escape_str($query))
->or_like('description',$this->db->escape_str($query))
->get('shop_search')
->num_rows();
every thing works well untill there is a ' and NOT " in the $query.
the error is : $query="d'"
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '%' OR
`description` LIKE '%d\\\\\\'%'' at line 3
SELECT `organization` FROM `default_shop_search` WHERE `title` LIKE
'%d\\\\\\'%' OR `description` LIKE '%d\\\\\\'%'
What am I missing here?
UPDATE:
dump of passed query:
Debug #1 of 1: string(2) "d'"

No comments:

Post a Comment