API / Minn\Query / CommentOrder

CommentOrder final class

Minn\Query\CommentOrder · public/minn/src/Minn/Query/CommentOrder.php · 100 lines

WP_Comment_Query's ORDER BY and LIMIT as the reference writes them (probe wp-comment-query-sql): no orderby means comment_date_gmt in the order asked; a list, a string of keys or a map of keys to directions each become a column, a meta value or the FIELD() list comment__in gives; a key it does not know is dropped (none left means comment_date_gmt), and unless comment_ID or comment__in is among them a comment_ID tiebreak follows, in the first date clause's direction or DESC.

Constants and properties

privateCOLUMNS = array ( 0 => 'comment_agent', 1 => 'comment_approved', 2 => 'comment_author', 3 => 'comment_author_email', 4 => 'comment_author_IP', 5 => 'comment_author_url', 6 => 'comment_content', 7 => 'comment_date', 8 => 'comment_date_gmt', 9 => 'comment_ID', 10 => 'comment_karma', 11 => 'comment_parent', 12 => 'comment_post_ID', 13 => 'comment_type', 14 => 'user_id', )
privateIDS = 'comment__in'

Public

staticdirection(mixed $order): string#

ASC when asked for, DESC for anything else.

staticbuild(array $qv, string $table, string $metaTable, array $metaClauses): string#

The ORDER BY body for the query's orderby and order ('' for none).

$qvarray<string, mixed>
$metaClausesarray<array-key, array<string, mixed>>the meta query's clauses, by name
staticclause(string $by, array $qv, string $table, string $metaTable, array $metaClauses): string#

One orderby key as SQL, or '' when the reference does not take it: a column, the meta value (as a number when asked), a named meta clause's cast value, or the FIELD() list keeping comment__in's order.

$qvarray<string, mixed>
$metaClausesarray<array-key, array<string, mixed>>
staticlimits(array $qv): string#

LIMIT from number, and the offset (or the page when no offset is given). @param array<string, mixed> $qv

$qvarray<string, mixed>

Internals 2

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

privatefield(mixed $given, string $table): string#

The comment__in ids in the order given, or '' when none are.

privatetiebreak(array $parts): string#

The tiebreak's direction: the first date clause's, else DESC. @param list<string> $parts

$partslist<string>