MysqlndUhPreparedStatement::prepare

(PECL mysqlnd-uh >= 1.0.0-alpha)

MysqlndUhPreparedStatement::preparePrepare an SQL statement for execution

说明

public MysqlndUhPreparedStatement::prepare ( mysqlnd_prepared_statement $statement , string $query ) : bool

Prepare an SQL statement for execution.

参数

statement

Mysqlnd prepared statement handle. Do not modify! Resource of type Mysqlnd Prepared Statement (internal only - you must not modify it!).

query

The query to be prepared.

返回值

Returns TRUE on success. Otherwise, returns FALSE

范例

Example #1 MysqlndUhPreparedStatement::prepare() example

<?php
class stmt_proxy extends MysqlndUhPreparedStatement {
 public function 
prepare($res$query) {
  
printf("%s(%s)\n"__METHOD__var_export(func_get_args(), true));
  
$query "SELECT 'No more you-know-what-I-mean for lunch, please' AS _msg FROM DUAL";
  
$ret parent::prepare($res$query);
  
printf("%s returns %s\n"__METHOD__var_export($rettrue));
  
var_dump($ret);
  return 
$ret;
 }
}
mysqlnd_uh_set_statement_proxy(new stmt_proxy());

$mysqli = new mysqli("localhost""root""""test");
$stmt $mysqli->prepare("SELECT 'Labskaus' AS _msg FROM DUAL");
$stmt->execute();
$msg NULL;
$stmt->bind_result($msg);
$stmt->fetch();
var_dump($msg);
?>

以上例程会输出:

stmt_proxy::prepare(array (
  0 => NULL,
  1 => 'SELECT \'Labskaus\' AS _msg FROM DUAL',
))
stmt_proxy::prepare returns true
bool(true)
string(46) "No more you-know-what-I-mean for lunch, please"

参见

相关文章
php cubrid mysql 兼容性函数 return the number of rows affected by the last sql statementphp cubrid 函数 prepare a sql statement for executionphp cubrid mysql 兼容性函数 escape special characters in a string for use in an sql statementphp ibm db2 函数 executes an sql statement directlyphp ibm db2 函数 executes a prepared sql statementphp firebird/interbase 函数 prepare a query for later binding of parameter placeholders and executionphp informix 函数 execute a previously prepared sql statementphp informix 函数 prepare an sql statement for executionphp ingres 函数 prepare a query for later executionphp maxdb 函数 prepare an sql statement for executionphp maxdb 函数 escapes special characters in a string for use in an sql statement taking into account the current charset of the connectionphp maxdb 函数 prepare an sql statement for executionphp odbc 函数 prepare and execute an sql statementphp sqlsrv 函数 executes a statement prepared with sqlsrv preparephp mysqli stmt prepare an sql statement for executionphp mysqlnduhpreparedstatement prepare an sql statement for executionphp sdo das relational 函数 executes an sql query passed as a prepared statement with a list of values to substitute for placeholders and return the results as a normalised data graphphp sqlite3 returns the number of database rows that were changed or inserted or deleted by the most recent sql statementphp sqlite3 prepares an sql statement for executionphp sqlite3stmt get the sql of the statement
关注编程学问公众号