class Replication (View source)

Replication helpers

Methods

__construct(DatabaseInterface $dbi)

No description

string
extractDbOrTable(string $string, string $what = 'db')

Extracts database or table name from string

ResultInterface|false|int
replicaControl(string $action, string|null $control, ConnectionType $connectionType)

Configures replication replica

ResultInterface|false
replicaChangePrimary(string $user, string $password, string $host, int $port, array $pos, bool $stop, bool $start, ConnectionType $connectionType)

Changes primary for replication replica

Connection|null
connectToPrimary(string $user, string $password, string|null $host = null, int|null $port = null, string|null $socket = null)

This function provides connection to remote mysql server

array
replicaBinLogPrimary(ConnectionType $connectionType)

Fetches position and file of current binary log on primary

Details

__construct(DatabaseInterface $dbi)

No description

Parameters

DatabaseInterface $dbi

string extractDbOrTable(string $string, string $what = 'db')

Extracts database or table name from string

Parameters

string $string

contains "dbname.tablename"

string $what

what to extract (db|table)

Return Value

string

the extracted part

ResultInterface|false|int replicaControl(string $action, string|null $control, ConnectionType $connectionType)

Configures replication replica

Parameters

string $action

possible values: START or STOP

string|null $control

default: null, possible values: SQL_THREAD or IO_THREAD or null. If it is set to null, it controls both SQL_THREAD and IO_THREAD

ConnectionType $connectionType

Return Value

ResultInterface|false|int

output of DatabaseInterface::tryQuery

ResultInterface|false replicaChangePrimary(string $user, string $password, string $host, int $port, array $pos, bool $stop, bool $start, ConnectionType $connectionType)

Changes primary for replication replica

Parameters

string $user

replication user on primary

string $password

password for the user

string $host

primary's hostname or IP

int $port

port, where mysql is running

array $pos

position of mysql replication, array should contain fields File and Position

bool $stop

shall we stop replica?

bool $start

shall we start replica?

ConnectionType $connectionType

Return Value

ResultInterface|false

output of CHANGE MASTER mysql command

Connection|null connectToPrimary(string $user, string $password, string|null $host = null, int|null $port = null, string|null $socket = null)

This function provides connection to remote mysql server

Parameters

string $user

mysql username

string $password

password for the user

string|null $host

mysql server's hostname or IP

int|null $port

mysql remote port

string|null $socket

path to unix socket

Return Value

Connection|null

array replicaBinLogPrimary(ConnectionType $connectionType)

Fetches position and file of current binary log on primary

Parameters

ConnectionType $connectionType

Return Value

array

an array containing File and Position in MySQL replication on primary server, useful for {\PhpMyAdmin\Replication\Replication::replicaChangePrimary()}.