Welcome Guest, Not a member yet? Register   Sign In
ODBC and LIKE gives weird query
#1

Hi,

I'm trying to make a simple query in Codigniter v3.0.0 like this:

PHP Code:
$this->db->select("cats");
$this->db->from("pets");
$this->db->like("name"'a''after'); 


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(
'dsn'   => 'pyramid',
'hostname' => '',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'odbc',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'WINDOWS-1252',
'dbcollat' => '',
    //'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
); 

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
protected $_like_escape_str ""//Replaced with an empty string 

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? Undecided
Does anyone know how to fix this?
Reply


Messages In This Thread
ODBC and LIKE gives weird query - by connyake - 02-16-2016, 01:32 AM
RE: ODBC and LIKE gives weird query - by mwhitney - 02-16-2016, 02:55 PM
RE: ODBC and LIKE gives weird query - by connyake - 02-23-2016, 05:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB