(PECL mysqlnd-uh >= 1.0.0-alpha)
MysqlndUhPreparedStatement::prepare — Prépare une requête SQL pour exécution
$statement
, string $query
) : boolPrépare une requête SQL pour exécution.
statement
Gestionnaire de requête préparée Mysqlnd.
Ne pas modifier ! Ressource de type
Mysqlnd Prepared Statement (internal only - you must not modify it!)
.
query
La requête à préparer.
Retourne true
en cas de succès, false
sinon.
Exemple #1 Exemple avec MysqlndUhPreparedStatement::prepare()
<?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 retourne %s\n", __METHOD__, var_export($ret, true));
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);
?>
L'exemple ci-dessus va afficher :
stmt_proxy::prepare(array ( 0 => NULL, 1 => 'SELECT \'Labskaus\' AS _msg FROM DUAL', )) stmt_proxy::prepare retourne true bool(true) string(46) "No more you-know-what-I-mean for lunch, please"