CUBRID 函数
PHP Manual

cubrid_real_escape_string

(PECL CUBRID >= 8.3.0)

cubrid_real_escape_stringReturns the escaped string version of the given string

说明

string cubrid_real_escape_string ( string $unescaped_string [, resource $conn_identifier ] )

This function returns the escaped string version of the given string. It pre-appends backslashes to the following characters: '. This function must always (with few exceptions) be used to make data safe before sending a query to CUBRID.

参数

unescaped_string

The string that is to be escaped.

conn_identifier

The CUBRID connection. If the connection identifier is not specified, the last link opened by cubrid_connect() is assumed.

返回值

Escaped string version of the given string, on success.

FALSE on failure.

范例

Example #1 cubrid_real_escape_string() example

<?php
    $user 
"'username'";
    
$password "\"pass\"";
    
$query sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
            
cubrid_real_escape_string($user),
            
cubrid_real_escape_string($password));
    
    echo 
$query;
?>

以上例程会输出:

Result:
SELECT * FROM users WHERE user='\'username\'' AND password='"pass"'

CUBRID 函数
PHP Manual