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 ()
 
 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 = []
 
 $meta = []
 
 $cachedSql = []
 

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 62 of file SelectStatement.php.

Member Function Documentation

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 44 of file SelectStatement.php.

__toString ( )

Get the query string.

Returns
String

Definition at line 72 of file SelectStatement.php.

getId ( )

Get the id of the statement.

Returns
String

Definition at line 80 of file SelectStatement.php.

getType ( )

Get the entity type associated with the statement.

Returns
String

Definition at line 88 of file SelectStatement.php.

isCached ( )

Check if the statement is cached already.

Returns
Boolean

Definition at line 96 of file SelectStatement.php.

setMeta (   $key,
  $value 
)

Add custom meta value.

Parameters
$key
$value

Definition at line 107 of file SelectStatement.php.

getMeta (   $key)

Get custom meta value.

Parameters
$key
Returns
Associative array

Definition at line 116 of file SelectStatement.php.

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 127 of file SelectStatement.php.

getParameters ( )

Get the select parameters.

Returns
Array

Definition at line 135 of file SelectStatement.php.

getRowCount ( )

Execute a count query and return the row count.

Returns
Integer

Definition at line 143 of file SelectStatement.php.

save ( )

Put the statement into the cache.

Definition at line 158 of file SelectStatement.php.

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

Definition at line 168 of file SelectStatement.php.

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 183 of file SelectStatement.php.

getSql ( )

Get the sql string for this statement.

Returns
String

Definition at line 208 of file SelectStatement.php.

query ( )

Execute the statement.

Returns
PDOStatement

Definition at line 221 of file SelectStatement.php.

getAdapter ( )
protected

Get the adapter corresponding to the statement's type.

Returns
AdapterInterface

Definition at line 232 of file SelectStatement.php.

static getCacheSection (   $type)
staticprotected

Get the cache section.

Parameters
$typeThe type
Returns
String

Definition at line 246 of file SelectStatement.php.

static getCacheId (   $id)
staticprotected

Get the compressed cache id from the id.

Parameters
$id
Returns
String

Definition at line 255 of file SelectStatement.php.

__sleep ( )

Serialization handlers.

Definition at line 263 of file SelectStatement.php.

__wakeup ( )

Definition at line 267 of file SelectStatement.php.

Member Data Documentation

const NO_CACHE = 'no_cache'

Definition at line 26 of file SelectStatement.php.

const CACHE_KEY = 'select'

Definition at line 27 of file SelectStatement.php.

$id = null
protected

Definition at line 29 of file SelectStatement.php.

$type = null
protected

Definition at line 30 of file SelectStatement.php.

$parameters = []
protected

Definition at line 31 of file SelectStatement.php.

$meta = []
protected

Definition at line 32 of file SelectStatement.php.

$cachedSql = []
protected

Definition at line 33 of file SelectStatement.php.