Meta final readonly class
Minn\Runtime\Meta · public/minn/src/Minn/Runtime/Meta.php · 242 lines
The four meta tables behind get_metadata and friends: reads by object, and the row-level writes the update and delete rules need.
Constants and properties
| private | TABLES = array ( 'post' => array ( 0 => 'postmeta', 1 => 'post_id', 2 => 'meta_id', ), 'user' => array ( 0 => 'usermeta', 1 => 'user_id', 2 => 'umeta_id', ), 'term' => array ( 0 => 'termmeta', 1 => 'term_id', 2 => 'meta_id', ), 'comment' => array ( 0 => 'commentmeta', 1 => 'comment_id', 2 => 'meta_id', ), ) | |
| private | readonly Minn\Db $db | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db)# | ||||
| static | knows(string $type): bool# | Whether an object type has a meta table. | |||
| static | clausesFromQueryVars(array $queryVars): array# | The meta query in flat query vars (meta_key, meta_value, the compare and type variants) as one clause, AND'd ahead of an explicit meta_query as its own group, as WP_Meta_Query::parse_query_vars reads them. An empty meta_value is no value.
@return array<array-key, mixed> | |||
| method | all(string $type, int $objectId): array# | Every row of an object's meta, values as stored, grouped by key in id order. @return array<string, list<string>> @return array<string, list<string>> | |||
| method | prime(string $type, array $objectIds): array# | update_meta_cache: each object's meta as all() gives it, the cached ones from the object cache and the rest read in one query and cached; an object with none has an empty list.
@return array<int, array<string, list<string>>> | |||
| method | keys(string $type): array# | Every meta key an object type uses, once each, in key order. @return list<string> @return list<string> | |||
| method | listing(string $type, int $objectId): array# | Every row of an object's meta by key, then id, as the post meta box lists them: the key, the value, the row's id and the object's, all as stored (strings). @return list<array<string, string>> | |||
| method | rowsOf(string $type, int $objectId): array# | Every row of an object's meta in id order, for removing them one by one. @return list<array{meta_id: int, meta_key: string, meta_value: string}> @return list<array{meta_id: int, meta_key: string, meta_value: string}> | |||
| method | byId(string $type, int $metaId): ?array# | One meta row by its id, under the table's own column names, values as stored; null when there is none. @return array<string, string>|null @return array<string, string>|null | |||
| method | columns(string $type): array# | The column holding the object's id, and the one holding the row's: post_id and meta_id, user_id and umeta_id. @return array{0: string, 1: string} @return array{0: string, 1: string} | |||
| method | rewrite(string $type, int $metaId, string $key, string $stored): void# | Sets one row's key and stored value. | |||
| method | add(string $type, int $objectId, string $key, string $stored): int# | Inserts a meta row and returns its id. | |||
| method | matching(string $type, int $objectId, string $key): array# | The rows of one key on one object, in id order. @return list<array{meta_id: int, meta_value: string}> @return list<array{meta_id: int, meta_value: string}> | |||
| static | idsToUpdate(array $rows, string $stored, ?string $previous): array# | Which of a key's rows an update touches: none when no previous value was named and the first row already holds the value, all of them when no previous value was named, otherwise only the rows holding it.
@return list<int> | |||
| method | updateRows(string $type, array $ids, string $stored): void# | Sets the value of the given meta rows. | |||
| method | find(string $type, ?int $objectId, string $key, ?string $stored): array# | The rows a delete would take: by key, for one object or all, optionally only a stored value. @return list<array{meta_id: int, object_id: int}> @return list<array{meta_id: int, object_id: int}> | |||
| method | objectsBelow(string $type, string $key, int $bound): array# | The objects whose value under the key is a number below the bound, lowest id first. @return list<int> @return list<int> | |||
| method | deleteRows(string $type, array $ids): void# | Deletes the given meta rows.
|
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | spec(string $type): array# | The table, object column, and row id column of a meta type. @return array{0: string, 1: string, 2: string} @return array{0: string, 1: string, 2: string} |
Nothing matches.