![]() |
ODBC and LIKE gives weird query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: ODBC and LIKE gives weird query (/showthread.php?tid=64393) |
ODBC and LIKE gives weird query - connyake - 02-16-2016 Hi, I'm trying to make a simple query in Codigniter v3.0.0 like this: PHP Code: $this->db->select("cats"); And then show it: PHP Code: echo $this->db->get_compiled_select(); Result: Quote:SELECT cats FROM pets WHERE name LIKE 'a%' {escape '!'} For some reason CI adds {escape '!'} at the end. Which of course generates an error when I try to run the query. Database config: PHP Code: $db['pyramid'] = array( I have tried to change the file system/database/drivers/odbc/odbc_driver.php like this: PHP Code: //protected $_like_escape_str = " {escape '%s'} "; Original It seems to escape as it should, but I'm not sure if something else depends on this. Is this a bug or is it just me that don't know how to use it properly? ![]() Does anyone know how to fix this? RE: ODBC and LIKE gives weird query - mwhitney - 02-16-2016 You may want to try upgrading to 3.0.4, as there were a few fixes to the database library in each version since 3.0. As far as I can tell, the output should look something like the following: Code: SELECT cats FROM pets WHERE name LIKE 'a!%' {escape '!'} For reference: https://msdn.microsoft.com/en-us/library/ms710128%28v=vs.85%29.aspx RE: ODBC and LIKE gives weird query - connyake - 02-23-2016 (02-16-2016, 02:55 PM)mwhitney Wrote: You may want to try upgrading to 3.0.4, as there were a few fixes to the database library in each version since 3.0. As far as I can tell, the output should look something like the following: Thank you for your response! I have now upgraded to 3.0.4 but still no luck. I also tried this: Code: $this->db->where("name LIKE '" . $this->db->escape_like_str('a%') . "' {escape '!'}", NULL, FALSE); and Code: $this->db->where("name LIKE '" . $this->db->escape_like_str('a') . "%' {escape '!'}", NULL, FALSE); Both of these give me a database syntax error (as before). It doesn't seems to accept the {escape '!'} part. Could it be due to the fact that there is a Pervasive database? |