Documentation Home
MySQL PHP API
Download this Manual
PDF (US Ltr) - 2.8Mb
PDF (A4) - 2.8Mb
EPUB - 457.0Kb
HTML Download (TGZ) - 396.3Kb
HTML Download (Zip) - 410.1Kb


MySQL PHP API  /  ...  /  MysqlndUhConnection::setServerOption

9.7.42 MysqlndUhConnection::setServerOption

Copyright 1997-2014 the PHP Documentation Group.

  • MysqlndUhConnection::setServerOption

    Sets a server option

Description

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

Sets a server option.

Parameters

connection

Mysqlnd connection handle. Do not modify!

option

The option to be set.

Return Values

Returns TRUE on success. Otherwise, returns FALSE

Examples

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

    

The above example will output:


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


See Also

mysqlnd_uh_set_connection_proxy
mysqli_real_connect
mysqli_options
mysqli_multi_query


User Comments
Sign Up Login You must be logged in to post a comment.