API / Minn\Runtime / WpdbSetup

WpdbSetup final class

Minn\Runtime\WpdbSetup · public/minn/src/Minn/Runtime/WpdbSetup.php · 135 lines

How the database object plugins hold as $wpdb is set up (probe db-mail-rewrite-doubts): it connects through its own db_connect, which sets the connection's names with prepare; set_prefix answers with the prefix it had, names the old tables too, and with set_table_names off changes only the base prefix; set_blog_id names one site's tables from the base prefix; CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE name the user tables; set_sql_mode reads the session's modes without a query of its own; a database that cannot be selected leaves the object not ready. One site only: the engine is never a network.

Public

staticconstruct(object $db, mixed $user, mixed $password, mixed $name, mixed $host): void#

Sets the object up over the engine's connection (wpdb::__construct).

staticconnect(object $db): bool#

Takes the engine's connection and sets its names (wpdb::db_connect): true.

staticcharset(object $db, mixed $dbh, mixed $charset, mixed $collate): void#

Sets a connection's charset and its names, with the collation when there is one (wpdb::set_charset).

staticprefix(object $db, mixed $prefix, mixed $setTableNames): mixed#

Sets the table prefix (wpdb::set_prefix): the base prefix it had (the new one the first time), or invalid_db_prefix for a prefix that is not letters, digits and underscores.

staticblog(object $db, mixed $blogId, mixed $networkId): int#

Switches the site the object answers for (wpdb::set_blog_id): the id it had.

statictables(object $db, mixed $scope, mixed $prefix): array#

The tables of a scope (wpdb::tables), by name to prefixed name unless the prefix is not wanted; the user tables are the custom ones where wp-config names them.

staticselect(object $db, mixed $name, mixed $dbh): void#

Selects a database; one that cannot be selected leaves the object not ready (wpdb::select).

staticsqlMode(object $db, mixed $modes): void#

Sets the session's SQL modes (wpdb::set_sql_mode): the given ones, or the session's own read from the connection, less the modes incompatible_sql_modes names.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatename(object $db, array $tables): void#
$tablesarray<string, string>names each table property