class PartitionQuery

PartitionQuery can be used to build a query with a window function See https://dev.mysql.com/doc/refman/8.0/en/window-functions.html for more details about window functions

TLDR: for each row from a query, perform a calculation using rows related to that row.

Practical example:

  • show me the last 2 articles in each news category
  • tell me the total articles in each category

$partitionQuery = PartitionQuery::fromQuery($articleQuery->withAutoSelects(),'category_id'); $partitionQuery->orderBy('published_at','DESC'); $partitionQuery->limit(2);

Note:

  • when using the result in model context, you should make use of Query::withAutoSelects() otherwise timestamp and binary columns will not be converted as expected

Methods

array
execute()

No description

static PartitionQuery
fromQuery(Query $query, string $partitionColumn)

No description

string
getInternalOrderBySQL()

OrderBy without ALIAS as these will NOT be available internally

string
getPartitionColumn()

No description

array
getPartitionCounts()

No description

string
getSQL()

No description

array
getScopeLimit()

No description

limit($length, $offset = 0)

No description

orderBy(string $field, string $sortDirection = Query::SORT_ASCENDING)

No description

setPartitionColumn(string $partitionColumn)

No description

Details

at line 162
array execute()

No description

Return Value

array

at line 52
static PartitionQuery fromQuery(Query $query, string $partitionColumn)

No description

Parameters

Query $query
string $partitionColumn

Return Value

PartitionQuery

at line 88
string getInternalOrderBySQL()

OrderBy without ALIAS as these will NOT be available internally

Return Value

string

at line 80
string getPartitionColumn()

No description

Return Value

string

at line 179
array getPartitionCounts()

No description

Return Value

array

at line 175
string getSQL()

No description

Return Value

string

at line 97
array getScopeLimit()

No description

Return Value

array

at line 74
PartitionQuery limit($length, $offset = 0)

No description

Parameters

$length
$offset

Return Value

PartitionQuery

at line 64
PartitionQuery orderBy(string $field, string $sortDirection = Query::SORT_ASCENDING)

No description

Parameters

string $field
string $sortDirection

Return Value

PartitionQuery

at line 59
PartitionQuery setPartitionColumn(string $partitionColumn)

No description

Parameters

string $partitionColumn

Return Value

PartitionQuery