API / Minn\Query / NetworkSql

NetworkSql final class

Minn\Query\NetworkSql · public/minn/src/Minn/Query/NetworkSql.php · 257 lines

The SQL WP_Site_Query and WP_Network_Query build from their variables (probe multisite-classes). A site query names only blog_id through its table (blogs); every other column stands bare. A network query names each column through its table (site). On one site both tables are unnamed, so the column is written after a bare dot, as the reference writes it.

Constants and properties

privateSITE_ORDER = array ( 'domain' => 'domain', 'last_updated' => 'last_updated', 'path' => 'path', 'registered' => 'registered', 'deleted' => 'deleted', 'spam' => 'spam', 'mature' => 'mature', 'archived' => 'archived', 'public' => 'public', 'network_id' => 'site_id', 'domain_length' => 'CHAR_LENGTH(domain)', 'path_length' => 'CHAR_LENGTH(path)', )

The columns a site query orders by, as each is written; blog_id is the table's own.

privateSITE_FLAGS = array ( 'archived' => '%s', 'mature' => '%d', 'spam' => '%d', 'deleted' => '%d', 'public' => '%d', 'lang_id' => '%d', )

The site flags as they are compared: archived as text, the rest as numbers, each followed by a space.

privatereadonly object $wpdb

Promoted from the constructor.

Public

new__construct(object $wpdb)#
methodsiteWhere(array $qv, ?Closure $columns = NULL): array#

A site query's conditions, in the reference's order: the ids, the networks, domains, paths, the flags, the languages, then the search (across the columns asked for, as $columns lets plugins change them).

$qvarray<string, mixed>
$columns(\Closure(list<string>): list<string>)|null
@return list<string>
methodnetworkWhere(array $qv): array#

A network query's conditions: the ids, domains, paths, then the search.

$qvarray<string, mixed>
@return list<string>
methodsiteSearch(string $search, array $columns): string#

A site query's search across columns, each a LIKE on the term anywhere, its stars wildcards.

$columnslist<string>
methodnetworkSearch(string $search, array $columns): string#

A network query's search: the same LIKEs, its stars kept.

$columnslist<string>
methodsiteOrderby(array $qv): string#

A site query's ORDER BY, or '' (an unknown column is passed over). @param array<string, mixed> $qv

$qvarray<string, mixed>
methodsiteOrderColumn(string $by, array $qv): ?string#

One column a site query orders by, as written; null for one it does not. @param array<string, mixed> $qv

$qvarray<string, mixed>
methodnetworkOrderby(array $qv): string#

A network query's ORDER BY, or ''. @param array<string, mixed> $qv

$qvarray<string, mixed>
methodnetworkOrderColumn(string $by, array $qv): ?string#

One column a network query orders by, as written; null for one it does not. @param array<string, mixed> $qv

$qvarray<string, mixed>
staticdirection(mixed $order): string#

ASC when asked for, in any case; anything else is DESC.

staticlimits(array $qv): string#

The LIMIT for a number and an offset; none without a number. @param array<string, mixed> $qv

$qvarray<string, mixed>
staticpieces(array $clauses, string $table, string $found): array#

The request from its clauses, joined as the reference joins them.

$clausesarray<string, string>fields, join, where, orderby, limits, groupby
@return array<string, string> the pieces kept on the query
methodids(string $request): array#

The ids a request finds. @return list<int>

@return list<int>
methodcount(string $request): int#

The count a counting request reads.

methodrowById(string $table, string $column, int $id): ?object#

A table's row by its id, or null when there is none.

methodfound(string $sql): int#

The rows a counted request found.

Internals 6

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

privatelikeAny(string $term, array $columns): string#
$columnslist<string>
privateorderby(array $qv, Closure $column, string $default): string#
$column\Closure(string): ?string@param array<string, mixed> $qv
privatefield(string $column, mixed $ids): string#

FIELD() over a list of ids, in the order given. @param mixed $ids

privateints(string $column, mixed $in, mixed $notIn): array#
@return list<string>
privatestrings(string $column, mixed $in, mixed $notIn): array#
@return list<string>
privatelist(mixed $value): array#

A list given as an array or a comma-separated string. @return list<mixed>

@return list<mixed>