Skip to content

Order

The Order trait sets and retrieves the order parameter for the query.

  • Full name: \Zemit\Mvc\Controller\Traits\Query\Order

Properties

defaultOrder

protected array|string|null $defaultOrder

order

protected ?\Phalcon\Support\Collection $order

Methods

initializeDefaultOrder

Initializes the default order for the instance.

public initializeDefaultOrder(): void

initializeOrder

Initializes the order parameter for the query.

public initializeOrder(): void

This method processes and sets the order parameter based on the "order" input received.

Throws:

If the order parameter is invalid.


setOrder

Sets the order for the query.

public setOrder(\Phalcon\Support\Collection|null $order): void

The provided order will replace any existing order previously set.

Parameters:

Parameter Type Description
$order **\Phalcon\Support\Collection null**

getOrder

Retrieves the order assigned to the query.

public getOrder(): \Phalcon\Support\Collection|null

If no order has been assigned, it will return null.

Return Value:

The order collection to assign to the query, or null if no order has been set.


setDefaultOrder

Sets the default order for the query.

public setDefaultOrder(array|string|null $defaultOrder): void

The default order will be used if no "order" parameter was provided

Parameters:

Parameter Type Description
$defaultOrder **array string

getDefaultOrder

Retrieves the default order for the query.

public getDefaultOrder(): array|string|null

Return Value:

The default order. It can be an array, a string, or null.


getSide

Returns the side value based on the given input.

protected getSide(string $side): string

Parameters:

Parameter Type Description
$side string The side value to be checked.

Return Value:

The side value. Returns 'desc' if the input is 'desc', otherwise returns 'asc'.