WpdbFields final class
Minn\Runtime\WpdbFields · public/minn/src/Minn/Runtime/WpdbFields.php · 404 lines
The database object's writers and the charset work behind them (probe db-mail-rewrite-doubts): an insert, replace, update or delete prepares one statement holding every value (a null written as NULL in it), and an insert or replace starts with insert_id at 0; the fields are checked against their columns, every field that would not fit named in the error; a table's columns are kept as the server's rows; a table that cannot be read gives the charset failure; text in a charset other than UTF-8, latin1 or binary is converted by the server; and check_safe_collation passes ASCII, the statements that read no rows, latin1 tables and tables whose text columns use only a binary or general UTF-8 collation.
Constants and properties
| private | SAFE_COLLATION = '/^utf8(?:mb[34])?_(?:bin|general_ci)$/i' |
Public
| static | insert(object $db, mixed $table, mixed $data, mixed $format, mixed $type): int|bool# | Inserts or replaces a row from processed fields (wpdb::_insert_replace_helper): rows written, or false. |
| static | update(object $db, mixed $table, mixed $data, mixed $where, mixed $format, mixed $whereFormat): int|bool# | Updates the rows a where list matches (wpdb::update): rows written, or false. |
| static | delete(object $db, mixed $table, mixed $where, mixed $whereFormat): int|bool# | Deletes the rows a where list matches (wpdb::delete): rows deleted, or false. |
| static | process(object $db, mixed $table, mixed $data, mixed $format): array|false# | The fields with their formats, column charsets and lengths, or false: when a column cannot be read, or when a value would not fit unchanged, last_error naming every such field (wpdb::process_fields). |
| static | charsets(object $db, mixed $data, mixed $table): array|false# | Each field with its column's charset, or false when the table cannot be read (wpdb::process_field_charsets). |
| static | lengths(object $db, mixed $data, mixed $table): array|false# | Each field with its column's length, or false when the table cannot be read (wpdb::process_field_lengths). |
| static | strip(object $db, mixed $data): mixed# | Each text value cut to what its column keeps (wpdb::strip_invalid_text): malformed bytes dropped for UTF-8, four-byte characters too for utf8, latin1 and binary kept, then cut to the column's length; text in any other charset goes through the server's conversion, in one query. |
| static | stripQuery(object $db, mixed $query): mixed# | A query with what its table (the connection, when it names none) cannot hold dropped (wpdb::strip_invalid_text_from_query). |
| static | safeCollation(object $db, mixed $query): bool# | Whether a query can skip the text check (wpdb::check_safe_collation). |
| static | tableCharset(object $db, mixed $table): mixed# | The charset a table's text columns share, kept for the request (wpdb::get_table_charset); pre_get_table_charset may answer first, and a table the server cannot describe is the charset failure. |
| static | columnCharset(object $db, mixed $table, mixed $column): mixed# | A column's charset: false for one that holds no text, the table's for a column it does not have (wpdb::get_col_charset). |
| static | columnLength(object $db, mixed $table, mixed $column): mixed# | The most a text or binary column holds, false for any other column, the charset failure for a table that cannot be read (wpdb::get_col_length). |
| static | queryCharset(object $db, string $query): string|false# | The charset a query's text is held to: its table's, the connection's when it names none or its table cannot be read. |
Internals 9
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | columns(object $db, mixed $table): array# | A table's columns, the server's SHOW FULL COLUMNS rows by lower-cased name, kept in col_meta; empty for a table the server cannot describe. @return array<string, object> | ||||||
| private | sharedCharset(array $columns): string|false# | The charset a table's columns come to (probe invalid-text): binary when one holds bytes, false when none holds text, else their one charset; latin1 beside others does not count, utf8 beside utf8mb4 is utf8, and any other mixture is ascii.
| ||||||
| private | charsetOf(object $db, string $table): mixed# | A table's charset through the object's own get_table_charset, which a subclass may answer. | ||||||
| private | unreadable(): mixed# | The table charset failure. | ||||||
| private | cut(string $value, string $charset, mixed $length): string# | A value cut to a column's length: bytes for latin1 (one character each) and the byte types, characters otherwise. | ||||||
| private | convert(object $db, array $data, array $server): mixed# | Text in charsets PHP does not judge here, converted by the server to the charset and back, cut to each column's length on the way.
| ||||||
| private | marks(array $fields): array# | The values a field list sends and the placeholder (or NULL) each takes in the statement.
@return array{0: list<mixed>, 1: list<string>} | ||||||
| private | conditions(array $conditions): array# | A where list as SQL: each field equal to its placeholder, or IS NULL.
@return array{0: list<mixed>, 1: string} | ||||||
| private | send(object $db, string $sql, array $values): int|bool# | Sends a writer's one prepared statement, its values already checked. |
Nothing matches.