Rechercher une fonction PHP

mysqlnd_ms_dump_servers

(No version information available, might only be in Git)

mysqlnd_ms_dump_serversReturns a list of currently configured servers

Description

mysqlnd_ms_dump_servers ( mixed $connection ) : array

Returns a list of currently configured servers.

PHP: mysqlnd_ms_dump_servers - Manual Home of Manuel PHP  Contents Haut

Parameters

connection

A MySQL connection handle obtained from any of the connect functions of the mysqli, mysql or PDO_MYSQL extensions.

PHP: mysqlnd_ms_dump_servers - Manual Home of Manuel PHP  Contents Haut

Return Values

FALSE on error. Otherwise, returns an array with two entries masters and slaves each of which contains an array listing all corresponding servers.

The function can be used to check and debug the list of servers currently used by the plugin. It is mostly useful when the list of servers changes at runtime, for example, when using MySQL Fabric.

masters and slaves server entries

Key Description Version
name_from_config

Server entry name from config, if appliciable. NULL if no configuration name is available.

Since 1.6.0.
hostname

Host name of the server.

Since 1.6.0.
user

Database user used to authenticate against the server.

Since 1.6.0.
port

TCP/IP port of the server.

Since 1.6.0.
socket

Unix domain socket of the server.

Since 1.6.0.

PHP: mysqlnd_ms_dump_servers - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

mysqlnd_ms_dump_servers() requires PECL mysqlnd_ms >> 1.6.0.

PHP: mysqlnd_ms_dump_servers - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 mysqlnd_ms_dump_servers() example

{
    "myapp": {
        "master": {
            "master1": {
                "host":"master1_host",
                "port":"master1_port",
                "socket":"master1_socket",
                "db":"master1_db",
                "user":"master1_user",
                "password":"master1_pw"
            }
        },
        "slave": {
             "slave_0": {
                 "host":"slave0_host",
                 "port":"slave0_port",
                 "socket":"slave0_socket",
                 "db":"slave0_db",
                 "user":"slave0_user",
                 "password":"slave0_pw"
             },
             "slave_1": {
                 "host":"slave1_host"
             }
        }
    }
}
<?php
$link 
mysqli_connect("myapp""global_user""global_pass""global_db"1234"global_socket");
var_dump(mysqlnd_ms_dump_servers($link);
?>

The above example will output:

array(2) {
  ["masters"]=>
  array(1) {
    [0]=>
    array(5) {
      ["name_from_config"]=>
      string(7) "master1"
      ["hostname"]=>
      string(12) "master1_host"
      ["user"]=>
      string(12) "master1_user"
      ["port"]=>
      int(3306)
      ["socket"]=>
      string(14) "master1_socket"
    }
  }
  ["slaves"]=>
  array(2) {
    [0]=>
    array(5) {
      ["name_from_config"]=>
      string(7) "slave_0"
      ["hostname"]=>
      string(11) "slave0_host"
      ["user"]=>
      string(11) "slave0_user"
      ["port"]=>
      int(3306)
      ["socket"]=>
      string(13) "slave0_socket"
    }
    [1]=>
    array(5) {
      ["name_from_config"]=>
      string(7) "slave_1"
      ["hostname"]=>
      string(11) "slave1_host"
      ["user"]=>
      string(12) "gloabal_user"
      ["port"]=>
      int(1234)
      ["socket"]=>
      string(13) "global_socket"
    }
  }
}

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mysqlnd-ms-dump-servers.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut