MysqlndUhConnection::setServerOption
(PECL mysqlnd-uh >= 1.0.0-alpha)
MysqlndUhConnection::setServerOption — Définit une option serveur
Description
public void MysqlndUhConnection::setServerOption
( mysqlnd_connection
$connection
, int $option
)Définit une option serveur.
Liste de paramètres
-
connection -
Gestionnaire de connexion Mysqlnd. Ne pas modifier !
-
option -
L'option à définir.
Valeurs de retour
Retourne TRUE en cas de succès. Sinon, retourne FALSE.
Exemples
Exemple #1 Exemple avec MysqlndUhConnection::setServerOption()
<?php
function server_option_to_string($option) {
$ret = 'unknown';
switch ($option) {
case MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON:
$ret = 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON';
break;
case MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_OFF:
$ret = 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON';
break;
}
return $ret;
}
class proxy extends MysqlndUhConnection {
public function setServerOption($res, $option) {
printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
printf("Option '%s' set\n", server_option_to_string($option));
$ret = parent::setServerOption($res, $option);
printf("%s returns %s\n", __METHOD__, var_export($ret, true));
return $ret;
}
}
mysqlnd_uh_set_connection_proxy(new proxy());
$mysqli = new mysqli("localhost", "root", "", "test");
$mysqli->multi_query("SELECT 1; SELECT 2");
?>L'exemple ci-dessus va afficher :
proxy::setServerOption(array ( 0 => NULL, 1 => 0, )) Option 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON' set proxy::setServerOption returns true
Voir aussi
- mysqlnd_uh_set_connection_proxy() - Installe un proxy pour les connexions mysqlnd
- mysqli_real_connect() - Ouvre une connexion à un serveur MySQL
- mysqli_options() - Définit les options
- mysqli_multi_query() - Exécute une requête MySQL multiple
