Overview

Namespaces

  • Charcoal
    • Loader
    • Model
      • Service
      • ServiceProvider
    • Source
      • Database
    • Validator

Classes

  • AbstractSource
  • DatabaseSource
  • DatabaseSourceConfig
  • Filter
  • Order
  • Pagination
  • SourceConfig

Interfaces

  • DatabaseSourceInterface
  • FilterInterface
  • OrderInterface
  • PaginationInterface
  • SourceInterface
  • StorableInterface

Traits

  • StorableTrait
  • Overview
  • Namespace
  • Class

Class Order

Order

Available modes: - asc to order in ascending (A-Z / 0-9) order. - desc to order in descending (Z-A / 9-0) order. - rand to order in a random fashion. - values to order by a defined array of properties. - custom to order by a custom SQL string.

Charcoal\Source\Order implements Charcoal\Source\OrderInterface

Direct known subclasses

Charcoal\Source\Database\DatabaseOrder
Namespace: Charcoal\Source
Located at Charcoal/Source/Order.php
Methods summary
public Charcoal\Source\Order
# setData( array $data )

Parameters

$data
The order data.

Returns

Charcoal\Source\Order
Chainable

Implementation of

Charcoal\Source\OrderInterface::setData()
public Charcoal\Source\Order
# setProperty( string $property )

Parameters

$property
The order property.

Returns

Charcoal\Source\Order
(Chainable)

Throws

InvalidArgumentException
If the property argument is not a string.

Implementation of

Charcoal\Source\OrderInterface::setProperty()
public string
# property( )

Returns

string

Implementation of

Charcoal\Source\OrderInterface::property()
public Charcoal\Source\Order
# setMode( string $mode )

Parameters

$mode
The order mode.

Returns

Charcoal\Source\Order
Chainable

Throws

InvalidArgumentException
If the mode is not a string or invalid.

Implementation of

Charcoal\Source\OrderInterface::setMode()
public string
# mode( )

Returns

string

Implementation of

Charcoal\Source\OrderInterface::mode()
public Charcoal\Source\Order
# setValues( string|array $values )

Set the values. Values are ignored if the mode is not "values"

Set the values. Values are ignored if the mode is not "values"

If the $values argument is a string, it will be split by ",". If it is an array, the values will be used as is. Otherwise, the function will throw an error

Parameters

$values
The order values.

Returns

Charcoal\Source\Order
(Chainable)

Throws

InvalidArgumentException
If the parameter is not an array or a string.

Implementation of

Charcoal\Source\OrderInterface::setValues()
public array
# values( )

Returns

array

Implementation of

Charcoal\Source\OrderInterface::values()
public Charcoal\Source\Order
# setString( string $sql )

Parameters

$sql
The custom order SQL string.

Returns

Charcoal\Source\Order
(Chainable)

Throws

InvalidArgumentException
If the parameter is not a valid operand.
public string
# string( )

Returns

string
public Charcoal\Source\Order
# setActive( boolean $active )

Parameters

$active
The active flag.

Returns

Charcoal\Source\Order
(Chainable)
public boolean
# active( )

Returns

boolean
protected array
# validModes( )

Supported modes

Supported modes

Returns

array
Constants summary
string MODE_ASC
# 'asc'
string MODE_DESC
# 'desc'
string MODE_RANDOM
# 'rand'
string MODE_VALUES
# 'values'
string MODE_CUSTOM
# 'custom'
Properties summary
protected string $property

The model property (SQL column).

The model property (SQL column).

#
protected string $mode

The sort mode.

The sort mode.

#
protected array $values

The values when self::$mode is self::MODE_VALUES.

The values when self::$mode is self::MODE_VALUES.

#
protected string $string

Raw SQL clause when self::$mode is self::MODE_CUSTOM.

Raw SQL clause when self::$mode is self::MODE_CUSTOM.

#
protected boolean $active

Whether the order is active.

Whether the order is active.

# true
API documentation generated by ApiGen