Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableStatusUnionQuery::extract_limit
Extracts the offset and row count from the LIMIT clause, or NULL when the query is unlimited or too deeply paginated to benefit (each branch would have to fetch offset + row count rows). The offset + row count cap also rejects the "unlimited" sentinel row count.
Method of the class: OrdersTableStatusUnionQuery{}
No Hooks.
Returns
Int[]|null. Array of [ offset, row count ], or NULL when ineligible.
Usage
// private - for code of main (parent) class only $result = $this->extract_limit( $limits ): ?array;
- $limits(string) (required)
- The LIMIT clause, including the keyword.
OrdersTableStatusUnionQuery::extract_limit() OrdersTableStatusUnionQuery::extract limit code WC 11.0.0
private function extract_limit( string $limits ): ?array {
if ( ! preg_match( '/^LIMIT (\d+), (\d+)$/', $limits, $limit_parts ) ) {
return null;
}
$offset = (int) $limit_parts[1];
$row_count = (int) $limit_parts[2];
if ( $row_count < 1 || ( $offset + $row_count ) > self::MAX_ROWS ) {
return null;
}
return array( $offset, $row_count );
}