Detailed Description

Select statement.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 24 of file SelectStatement.php.

+ Inheritance diagram for SelectStatement:

Public Member Functions

 __construct (RDBMapper $mapper, $id=self::NO_CACHE)
 
 __toString ()
 
 getId ()
 
 getType ()
 
 isCached ()
 
 setMeta ($key, $value)
 
 getMeta ($key)
 
 setParameters ($parameters)
 
 getParameters ($stripColons=false)
 
 getRowCount ()
 
 save ()
 
 join ($name, $on, $columns=self::SQL_STAR, $type=self::JOIN_INNER)
 
 addColumns (array $columns, $joinName=null)
 
 getSql ()
 
 query ()
 
 __sleep ()
 
 __wakeup ()
 

Static Public Member Functions

static get (RDBMapper $mapper, $id=self::NO_CACHE)
 

Public Attributes

const NO_CACHE = 'no_cache'
 
const CACHE_KEY = 'select'
 

Protected Member Functions

 getAdapter ()
 

Static Protected Member Functions

static getCacheSection ($type)
 
static getCacheId ($id)
 

Protected Attributes

 $id = null
 
 $type = null
 
 $parameters = []
 
 $parametersStripped = []
 
 $meta = []
 
 $cachedSql = []
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( RDBMapper  $mapper,
  $id = self::NO_CACHE 
)

Constructor.

Parameters
$mapperRDBMapper instance
$idThe statement id (optional, default: SelectStatement::NO_CACHE)

Definition at line 64 of file SelectStatement.php.

Member Function Documentation

◆ get()

static get ( RDBMapper  $mapper,
  $id = self::NO_CACHE 
)
static

Get the SelectStatement instance with the given id.

If the id equals SelectStatement::NO_CACHE or is not cached, a new one will be created.

Parameters
$mapperRDBMapper instance used to retrieve the database adapter
$idThe statement id (optional, default: SelectStatement::NO_CACHE)
Returns
SelectStatement

Definition at line 45 of file SelectStatement.php.

◆ __toString()

__toString ( )

Get the query string.

Returns
String

Definition at line 75 of file SelectStatement.php.

◆ getId()

getId ( )

Get the id of the statement.

Returns
String

Definition at line 83 of file SelectStatement.php.

◆ getType()

getType ( )

Get the entity type associated with the statement.

Returns
String

Definition at line 91 of file SelectStatement.php.

◆ isCached()

isCached ( )

Check if the statement is cached already.

Returns
Boolean

Definition at line 99 of file SelectStatement.php.

◆ setMeta()

setMeta (   $key,
  $value 
)

Add custom meta value.

Parameters
$key
$value

Definition at line 110 of file SelectStatement.php.

◆ getMeta()

getMeta (   $key)

Get custom meta value.

Parameters
$key
Returns
Associative array

Definition at line 119 of file SelectStatement.php.

◆ setParameters()

setParameters (   $parameters)

Set the parameter values to replace the placeholders with when doing the select.

Parameters
$parametersAssociative array with placeholders as keys

Definition at line 130 of file SelectStatement.php.

◆ getParameters()

getParameters (   $stripColons = false)

Get the select parameters.

Parameters
$stripColonsIndicates whether to strip the colon character from the parameter name or not (default: false)
Returns
Array

Definition at line 143 of file SelectStatement.php.

◆ getRowCount()

getRowCount ( )

Execute a count query and return the row count.

Returns
Integer

Definition at line 151 of file SelectStatement.php.

◆ save()

save ( )

Put the statement into the cache.

Definition at line 166 of file SelectStatement.php.

◆ join()

join (   $name,
  $on,
  $columns = self::SQL_STAR,
  $type = self::JOIN_INNER 
)
See also
Select::join()

Definition at line 176 of file SelectStatement.php.

◆ addColumns()

addColumns ( array  $columns,
  $joinName = null 
)

Add columns to the statement.

Parameters
$columnsArray of columns (
See also
Select::columns())
Parameters
$joinNameThe name of the join to which the columns belong

Definition at line 191 of file SelectStatement.php.

◆ getSql()

getSql ( )

Get the sql string for this statement.

Returns
String

Definition at line 216 of file SelectStatement.php.

◆ query()

query ( )

Execute the statement.

Returns
PDOStatement

Definition at line 229 of file SelectStatement.php.

◆ getAdapter()

getAdapter ( )
protected

Get the adapter corresponding to the statement's type.

Returns
AdapterInterface

Definition at line 240 of file SelectStatement.php.

◆ getCacheSection()

static getCacheSection (   $type)
staticprotected

Get the cache section.

Parameters
$typeThe type
Returns
String

Definition at line 249 of file SelectStatement.php.

◆ getCacheId()

static getCacheId (   $id)
staticprotected

Get the compressed cache id from the id.

Parameters
$id
Returns
String

Definition at line 258 of file SelectStatement.php.

◆ __sleep()

__sleep ( )

Serialization handlers.

Definition at line 266 of file SelectStatement.php.

◆ __wakeup()

__wakeup ( )

Definition at line 270 of file SelectStatement.php.

Member Data Documentation

◆ NO_CACHE

const NO_CACHE = 'no_cache'

Definition at line 26 of file SelectStatement.php.

◆ CACHE_KEY

const CACHE_KEY = 'select'

Definition at line 27 of file SelectStatement.php.

◆ $id

$id = null
protected

Definition at line 29 of file SelectStatement.php.

◆ $type

$type = null
protected

Definition at line 30 of file SelectStatement.php.

◆ $parameters

$parameters = []
protected

Definition at line 31 of file SelectStatement.php.

◆ $parametersStripped

$parametersStripped = []
protected

Definition at line 32 of file SelectStatement.php.

◆ $meta

$meta = []
protected

Definition at line 33 of file SelectStatement.php.

◆ $cachedSql

$cachedSql = []
protected

Definition at line 34 of file SelectStatement.php.