The cubrid_real_escape_string function returns the escaped string version of the given string. Follow two escape sequence methods should be supported. On the quoted escape sequence, a string quoted with " or ' can be applied when system parameter ansi_quotes is set to "yes". If this option is set to "no", only a string quoted with ' can be applied. The default value is "no".
Quoted escape sequence:
Backslash escape sequence: This sequence is on by system parameter no_backslash_escapes.
The following characters can be escaped by backslash: \', \", \n, \r, \t, \\, \% \_.
If this option is set to "no", backslash escaping will work. The default value is "yes".
string cubrid_real_escape_string (string $unescaped_string [, resource $link_identifier ] )
< ?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$unescaped_str = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$escaped_str = cubrid_real_escape_string($unescaped_str);
$len = strlen($unescaped_str);
@cubrid_execute($conn, "DROP TABLE cubrid_test");
cubrid_execute($conn, "CREATE TABLE cubrid_test (t char($len))");
cubrid_execute($conn, "INSERT INTO cubrid_test (t) VALUES('$escaped_str')");
$req = cubrid_execute($conn, "SELECT * FROM cubrid_test");
$row = cubrid_fetch_assoc($req);
var_dump($row);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
The above example will output:
array(1) {
["t"]=>
string(95) " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
}