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
| private | SITE_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. |
| private | SITE_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. |
| private | readonly object $wpdb | Promoted from the constructor. |
Public
| new | __construct(object $wpdb)# | |||||||
| method | siteWhere(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).
@return list<string> | ||||||
| method | networkWhere(array $qv): array# | A network query's conditions: the ids, domains, paths, then the search.
@return list<string> | ||||||
| method | siteSearch(string $search, array $columns): string# | A site query's search across columns, each a LIKE on the term anywhere, its stars wildcards.
| ||||||
| method | networkSearch(string $search, array $columns): string# | A network query's search: the same LIKEs, its stars kept.
| ||||||
| method | siteOrderby(array $qv): string# | A site query's ORDER BY, or '' (an unknown column is passed over). @param array<string, mixed> $qv
| ||||||
| method | siteOrderColumn(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
| ||||||
| method | networkOrderby(array $qv): string# | A network query's ORDER BY, or ''. @param array<string, mixed> $qv
| ||||||
| method | networkOrderColumn(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
| ||||||
| static | direction(mixed $order): string# | ASC when asked for, in any case; anything else is DESC. | ||||||
| static | limits(array $qv): string# | The LIMIT for a number and an offset; none without a number. @param array<string, mixed> $qv
| ||||||
| static | pieces(array $clauses, string $table, string $found): array# | The request from its clauses, joined as the reference joins them.
@return array<string, string> the pieces kept on the query | ||||||
| method | ids(string $request): array# | The ids a request finds. @return list<int> @return list<int> | ||||||
| method | count(string $request): int# | The count a counting request reads. | ||||||
| method | rowById(string $table, string $column, int $id): ?object# | A table's row by its id, or null when there is none. | ||||||
| method | found(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.
| private | likeAny(string $term, array $columns): string# |
| |||
| private | orderby(array $qv, Closure $column, string $default): string# |
| |||
| private | field(string $column, mixed $ids): string# | FIELD() over a list of ids, in the order given. @param mixed $ids | |||
| private | ints(string $column, mixed $in, mixed $notIn): array# | @return list<string> | |||
| private | strings(string $column, mixed $in, mixed $notIn): array# | @return list<string> | |||
| private | list(mixed $value): array# | A list given as an array or a comma-separated string. @return list<mixed> @return list<mixed> |
Nothing matches.