Detailed Description

Select statement.

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

Definition at line 25 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)
 
 getAliasNames ($table)
 
 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 67 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 48 of file SelectStatement.php.

◆ __toString()

__toString ( )

Get the query string.

Returns
String

Definition at line 81 of file SelectStatement.php.

◆ getId()

getId ( )

Get the id of the statement.

Returns
String

Definition at line 89 of file SelectStatement.php.

◆ getType()

getType ( )

Get the entity type associated with the statement.

Returns
String

Definition at line 97 of file SelectStatement.php.

◆ isCached()

isCached ( )

Check if the statement is cached already.

Returns
Boolean

Definition at line 105 of file SelectStatement.php.

◆ setMeta()

setMeta (   $key,
  $value 
)

Add custom meta value.

Parameters
$key
$value

Definition at line 116 of file SelectStatement.php.

◆ getMeta()

getMeta (   $key)

Get custom meta value.

Parameters
$key
Returns
Associative array

Definition at line 125 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 136 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 149 of file SelectStatement.php.

◆ getRowCount()

getRowCount ( )

Execute a count query and return the row count.

Returns
Integer

Definition at line 157 of file SelectStatement.php.

◆ save()

save ( )

Put the statement into the cache.

Definition at line 207 of file SelectStatement.php.

◆ join()

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

Definition at line 217 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 232 of file SelectStatement.php.

◆ getAliasNames()

getAliasNames (   $table)

Get the alias names for a table name.

Parameters
$tables
Returns
Array

Definition at line 258 of file SelectStatement.php.

◆ getSql()

getSql ( )

Get the sql string for this statement.

Returns
String

Definition at line 276 of file SelectStatement.php.

◆ query()

query ( )

Execute the statement.

Returns
PDOStatement

Definition at line 293 of file SelectStatement.php.

◆ getAdapter()

getAdapter ( )
protected

Get the adapter corresponding to the statement's type.

Returns
AdapterInterface

Definition at line 310 of file SelectStatement.php.

◆ getCacheSection()

static getCacheSection (   $type)
staticprotected

Get the cache section.

Parameters
$typeThe type
Returns
String

Definition at line 319 of file SelectStatement.php.

◆ getCacheId()

static getCacheId (   $id)
staticprotected

Get the compressed cache id from the id.

Parameters
$id
Returns
String

Definition at line 328 of file SelectStatement.php.

◆ __sleep()

__sleep ( )

Serialization handlers.

Definition at line 336 of file SelectStatement.php.

◆ __wakeup()

__wakeup ( )

Definition at line 340 of file SelectStatement.php.

Member Data Documentation

◆ NO_CACHE

const NO_CACHE = 'no_cache'

Definition at line 27 of file SelectStatement.php.

◆ CACHE_KEY

const CACHE_KEY = 'select'

Definition at line 28 of file SelectStatement.php.

◆ $id

$id = null
protected

Definition at line 30 of file SelectStatement.php.

◆ $type

$type = null
protected

Definition at line 31 of file SelectStatement.php.

◆ $parameters

$parameters = []
protected

Definition at line 32 of file SelectStatement.php.

◆ $parametersStripped

$parametersStripped = []
protected

Definition at line 33 of file SelectStatement.php.

◆ $meta

$meta = []
protected

Definition at line 34 of file SelectStatement.php.

◆ $cachedSql

$cachedSql = []
protected

Definition at line 35 of file SelectStatement.php.