PHP Unconference Europe 2015

MysqlndUhConnection::setServerOption

(PECL mysqlnd-uh >= 1.0.0-alpha)

MysqlndUhConnection::setServerOptionSets a server option

Descrição

public void MysqlndUhConnection::setServerOption ( mysqlnd_connection $connection , int $option )

Sets a server option.

Parâmetros

connection

Mysqlnd connection handle. Do not modify!

option

The option to be set.

Valor Retornado

Returns TRUE on success. Otherwise, returns FALSE

Exemplos

Exemplo #1 MysqlndUhConnection::setServerOption() example

<?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($rettrue));
  return 
$ret;
 }
}
mysqlnd_uh_set_connection_proxy(new proxy());
$mysqli = new mysqli("localhost""root""""test");
$mysqli->multi_query("SELECT 1; SELECT 2");
?>

O exemplo acima irá imprimir:

proxy::setServerOption(array (
  0 => NULL,
  1 => 0,
))
Option 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON' set
proxy::setServerOption returns true

Veja Também

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top