Pages::select($select)

Version 2022.2

Select given values

Return value

Array

Arguments

$select
Select definitions
String comma delimited list
Array List of definitions

Full documentation

Select values

Get list of new projects

$data = $this->get('pages','project')
    ->addWhere('status','New')
    ->select(Array(
       'id' => '',
       'client' => '',
       'amount' => '',
       'order_date' => ''
    ));

Get grouped data

Get list of clients that have new projects

$data = $this->get('pages','project')
    ->addWhere('status','New')
    ->setGroup('client')
    ->select(Array(
       'client' => '',
       'pcs' => 'COUNT',
       'average_amount' => 'AVG(amount)',
       'total_amount' => 'SUM(amount)',
       'first' => 'MIN(order_date)',
       'last' => 'MAX(order_date)'
    ));

Allowed select functions

String functions

Function Description
LOWER() To lower case
UCASE()
UPPER() To upper case
CONCAT() Combine multiple values as string

Numeric functions

Function Description
ROUND() Round to closest
FLOOR() Round down
CEIL() Round up
CEILING() Closest integer that is bigger than or equal

Time functions

Function Description
SEC_TO_TIME()
TIME_TO_SEC()
TIME()
HOUR()
MINUTE()

Date functions

Functions Description
DATE()
YEAR()
QUARTER()
MONTH()
WEEK()
WEEKDAY()
DATE_FORMAT()
YEARWEEK()
DAY()
DAYOFMONTH()
DAYOFWEEK()
DAYOFYEAR()
MONTH()

Group functions

Function Description
COUNT() Count number of rows
SUM() Sum of the values
MAX() Max value
MIN() Min value
AVG() Value average