Class xPDOCriteria

Description

Encapsulates a SQL query into a PDOStatement with a set of bindings.

Constants

Located in /xpdo.class.php (line 2227)


	
			
Direct descendents
Class Description
Abstract class xPDOQuery An xPDOCriteria derivative with methods for constructing complex statements.
Variable Summary
 mixed $bindings
 mixed $cacheFlag
 mixed $sql
 mixed $stmt
Method Summary
 xPDOCriteria __construct (xPDO &$xpdo, [string $sql = ''], [array $bindings = array ()], [boolean|integer $cacheFlag = false])
 void bind ([array $bindings = array ()], [boolean $byValue = true], [boolean|integer $cacheFlag = false])
 boolean equals (object $obj)
 PDOStatement prepare ([array $bindings = array ()], [boolean $byValue = true], [boolean|integer $cacheFlag = null])
 string toSQL ()
Variables
mixed $bindings = array () (line 2230)

Constants

  • access: public
mixed $cacheFlag = false (line 2231)

Constants

  • access: public
mixed $sql = '' (line 2228)

Constants

  • access: public
mixed $stmt = null (line 2229)

Constants

  • access: public
Methods
Constructor __construct (line 2252)

The constructor for a new xPDOCriteria instance.

Constants

The constructor optionally prepares provided SQL and/or parameter bindings. Setting the bindings via the constructor or with the xPDOCriteria::bind() function allows you to make use of the data object caching layer.

The statement will not be prepared immediately if the cacheFlag value is true or a positive integer, in order to allow the result to be found in the cache before being queried from an actual database connection.

  • access: public
xPDOCriteria __construct (xPDO &$xpdo, [string $sql = ''], [array $bindings = array ()], [boolean|integer $cacheFlag = false])
  • xPDO &$xpdo: An xPDO instance that will control this criteria.
  • string $sql: The SQL statement.
  • array $bindings: Bindings to bind to the criteria.
  • boolean|integer $cacheFlag: Indicates if the result set from the criteria is to be cached (true|false) or optionally a TTL in seconds.

Redefined in descendants as:
bind (line 2287)

Binds an array of key/value pairs to the xPDOCriteria prepared statement.

Constants

Use this method to bind parameters in a way that makes it possible to cache results of previous executions of the criteria or compare the criteria to other individual or collections of criteria.

  • access: public
void bind ([array $bindings = array ()], [boolean $byValue = true], [boolean|integer $cacheFlag = false])
  • array $bindings: Bindings to merge with any existing bindings defined for this xPDOCriteria instance. Bindings can be simple associative array of key-value pairs or the value for each key can contain elements titled value, type, and length corresponding to the appropriate parameters in the PDOStatement::bindValue() and PDOStatement::bindParam() functions.
  • boolean $byValue: Determines if the $bindings are to be bound as parameters (by variable reference, the default behavior) or by direct value (if true).
  • boolean|integer $cacheFlag: The cacheFlag indicates the cache state of the xPDOCriteria object and can be absolutely off (false), absolutely on (true), or an integer indicating the number of seconds the result will live in the cache.
equals (line 2321)

Compares to see if two xPDOCriteria instances are the same.

Constants

  • return: true if they are both equal is SQL and bindings, otherwise false.
  • access: public
boolean equals (object $obj)
  • object $obj: A xPDOCriteria object to compare to this one.
prepare (line 2350)

Prepares the sql and bindings of this instance into a PDOStatement.

Constants

The xPDOCriteria::$sql attribute must be set in order to prepare the statement. You can also pass bindings directly to this function and they will be run through xPDOCriteria::bind() if the statement is successfully prepared.

If the xPDOCriteria::$stmt already exists, it is simply returned.

  • return: The prepared statement, ready to execute.
  • access: public
PDOStatement prepare ([array $bindings = array ()], [boolean $byValue = true], [boolean|integer $cacheFlag = null])
  • array $bindings: Bindings to merge with any existing bindings defined for this xPDOCriteria instance. Bindings can be simple associative array of key-value pairs or the value for each key can contain elements titled value, type, and length corresponding to the appropriate parameters in the PDOStatement::bindValue() and PDOStatement::bindParam() functions.
  • boolean $byValue: Determines if the $bindings are to be bound as parameters (by variable reference, the default behavior) or by direct value (if true).
  • boolean|integer $cacheFlag: The cacheFlag indicates the cache state of the xPDOCriteria object and can be absolutely off (false), absolutely on (true), or an integer indicating the number of seconds the result will live in the cache.

Redefined in descendants as:
toSQL (line 2366)

Converts the current xPDOQuery to parsed SQL.

Constants

  • return: The parsed SQL query.
  • access: public
string toSQL ()

Documentation generated on Mon, 27 Dec 2010 11:08:26 -0700 by phpDocumentor 1.4.3