summaryrefslogtreecommitdiff
path: root/vendor/thecodingmachine/safe/generated/mysqlndMs.php
blob: 2fd4f32a29aff1e51a0da38fa159ea1dd046c27e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php

namespace Safe;

use Safe\Exceptions\MysqlndMsException;

/**
 * Returns a list of currently configured servers.
 *
 * @param mixed $connection A MySQL connection handle obtained from any of the
 * connect functions of the mysqli,
 * mysql or
 * PDO_MYSQL extensions.
 * @return array 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
 * @throws MysqlndMsException
 *
 */
function mysqlnd_ms_dump_servers($connection): array
{
    error_clear_last();
    $result = \mysqlnd_ms_dump_servers($connection);
    if ($result === false) {
        throw MysqlndMsException::createFromPhpError();
    }
    return $result;
}


/**
 * MySQL Fabric related.
 *
 * Switch the connection to the nodes handling global sharding queries
 * for the given table name.
 *
 * @param mixed $connection A MySQL connection handle obtained from any of the
 * connect functions of the mysqli,
 * mysql or
 * PDO_MYSQL extensions.
 * @param mixed $table_name The table name to ask Fabric about.
 * @return array FALSE on error. Otherwise, TRUE
 * @throws MysqlndMsException
 *
 */
function mysqlnd_ms_fabric_select_global($connection, $table_name): array
{
    error_clear_last();
    $result = \mysqlnd_ms_fabric_select_global($connection, $table_name);
    if ($result === false) {
        throw MysqlndMsException::createFromPhpError();
    }
    return $result;
}


/**
 * MySQL Fabric related.
 *
 * Switch the connection to the shards responsible for the
 * given table name and shard key.
 *
 * @param mixed $connection A MySQL connection handle obtained from any of the
 * connect functions of the mysqli,
 * mysql or
 * PDO_MYSQL extensions.
 * @param mixed $table_name The table name to ask Fabric about.
 * @param mixed $shard_key The shard key to ask Fabric about.
 * @return array FALSE on error. Otherwise, TRUE
 * @throws MysqlndMsException
 *
 */
function mysqlnd_ms_fabric_select_shard($connection, $table_name, $shard_key): array
{
    error_clear_last();
    $result = \mysqlnd_ms_fabric_select_shard($connection, $table_name, $shard_key);
    if ($result === false) {
        throw MysqlndMsException::createFromPhpError();
    }
    return $result;
}


/**
 * Returns an array which describes the last used connection from the plugins
 * connection pool currently pointed to by the user connection handle. If using the
 * plugin, a user connection handle represents a pool of database connections.
 * It is not possible to tell from the user connection handles properties to which
 * database server from the pool the user connection handle points.
 *
 * The function can be used to debug or monitor PECL mysqlnd_ms.
 *
 * @param mixed $connection A MySQL connection handle obtained from any of the
 * connect functions of the mysqli,
 * mysql or
 * PDO_MYSQL extensions.
 * @return array FALSE on error. Otherwise, an
 * array which describes the connection used to
 * execute the last statement on.
 *
 * Array which describes the connection.
 * @throws MysqlndMsException
 *
 */
function mysqlnd_ms_get_last_used_connection($connection): array
{
    error_clear_last();
    $result = \mysqlnd_ms_get_last_used_connection($connection);
    if ($result === false) {
        throw MysqlndMsException::createFromPhpError();
    }
    return $result;
}