This topic is locked
[SOLVED]

 db2 function addSlashes

4/10/2015 4:22:53 PM
PHPRunner General questions
F
fantasmino author

Hi everybody,

I have an error when there is an apostrophe ' in a database field

My db connection is odbc db2

I have get a look inside the connection an change the function addSlashes in \connections\dbfunctions\DB2Functions.php

it was:

public function addSlashes( $str )

{

//$search_array = array('\\', '\'', "\x00", "\x0a", "\x0d", "\x1a");

//$replace_array = array('\\\\', '\\\'', '\0', '\n', '\r', '\Z');

//return str_replace($search_array, $replace_array, $str);

return addslashes($str);

}



and I change it to:

public function addSlashes( $str )

{

//$search_array = array('\\', '\'', "\x00", "\x0a", "\x0d", "\x1a");

//$replace_array = array('\\\\', '\\\'', '\0', '\n', '\r', '\Z');

//return str_replace($search_array, $replace_array, $str);

return str_replace("'", "''", $str);

return addslashes($str);

}



Now seems ok,

can someone please tell me that is the correct way?

Thank you