Class QModelTrait
This trait class is a mixin helper for all the generated Model classes. It works together with the code generator
to create particular functions that are common to all the classes. For historical reasons, and to prevent problems
with polymorhpism, this is a trait and not a base class.
Methods summary
protected static
string
|
#
BuildQueryStatement( QQueryBuilder & $objQueryBuilder, QQCondition $objConditions, QQClause[] $objOptionalClauses, mixed[] $mixParameterArray, boolean $blnCountOnly )
Takes a query builder object and outputs the sql query that corresponds to its structure and the given parameters.
Takes a query builder object and outputs the sql query that corresponds to its structure and the given parameters.
Parameters
- $objQueryBuilder
- $objQueryBuilder the QueryBuilder object that will be created
- $objConditions
- any conditions on the query, itself
- $objOptionalClauses
- additional optional QQClause object or array of QQClause objects for this query
- $mixParameterArray
- a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
- $blnCountOnly
- only select a rowcount
Returns
string the query statement
Throws
|
protected static
null|QModelBase
|
#
_QuerySingle( QQCondition $objConditions, null $objOptionalClauses = null, mixed[] $mixParameterArray = null )
Static Qcubed Query method to query for a single ClassName ?> object.
Uses BuildQueryStatment to perform most of the work.
Is called by QuerySincle function of each object so that the correct return type will be put in the comments.
Static Qcubed Query method to query for a single ClassName ?> object.
Uses BuildQueryStatment to perform most of the work.
Is called by QuerySincle function of each object so that the correct return type will be put in the comments.
Parameters
- $objConditions
- any conditions on the query, itself
- $objOptionalClauses
- $mixParameterArray
- a array of name-value pairs to perform PrepareStatement with
Returns
null|QModelBase the queried object
Throws
|
protected static
mixed[]
|
#
_QueryArray( QQCondition $objConditions, QQClause[] |null $objOptionalClauses = null, mixed[]|null $mixParameterArray = null )
Static Qcubed Query method to query for an array of objects.
Uses BuildQueryStatment to perform most of the work.
Is called by QueryArray function of each object so that the correct return type will be put in the comments.
Static Qcubed Query method to query for an array of objects.
Uses BuildQueryStatment to perform most of the work.
Is called by QueryArray function of each object so that the correct return type will be put in the comments.
Parameters
- $objConditions
- any conditions on the query, itself
- $objOptionalClauses
- additional optional QQClause objects for this query
- $mixParameterArray
- an array of name-value pairs to substitute in to the placeholders in the query, if needed
Returns
mixed[] an array of objects
Throws
|
public static
QDatabaseResultBase
|
#
QueryCursor( QQCondition $objConditions, QQClause[] $objOptionalClauses = null, mixed[] $mixParameterArray = null )
Static Qcubed query method to issue a query and get a cursor to progressively fetch its results.
Uses BuildQueryStatment to perform most of the work.
Static Qcubed query method to issue a query and get a cursor to progressively fetch its results.
Uses BuildQueryStatment to perform most of the work.
Parameters
- $objConditions
- any conditions on the query, itself
- $objOptionalClauses
- additional optional QQClause objects for this query
- $mixParameterArray
- an array of name-value pairs to substitute in to the placeholders in the query, if needed
Returns
Throws
|
public static
integer
|
#
QueryCount( QQCondition $objConditions, QQClause[] $objOptionalClauses = null, mixed[] $mixParameterArray = null )
Static Qcubed Query method to query for a count of objects.
Uses BuildQueryStatment to perform most of the work.
Static Qcubed Query method to query for a count of objects.
Uses BuildQueryStatment to perform most of the work.
Parameters
- $objConditions
- any conditions on the query, itself
- $objOptionalClauses
- additional optional QQClause objects for this query
- $mixParameterArray
- a array of name-value pairs to perform PrepareStatement with
Returns
integer the count of queried objects as an integer
|
public static
|
|
public static
boolean|null
|
#
ExpandArray( QDatabaseRowBase $objDbRow, string $strAliasPrefix, QQNode $objNode, QModelBase[] $objPreviousItemArray, string[] $strColumnAliasArray )
Do a possible array expansion on the given node. If the node is an ExpandAsArray node,
it will add to the corresponding array in the object. Otherwise, it will follow the node
so that any leaf expansions can be handled.
Do a possible array expansion on the given node. If the node is an ExpandAsArray node,
it will add to the corresponding array in the object. Otherwise, it will follow the node
so that any leaf expansions can be handled.
Parameters
- $objDbRow
- $strAliasPrefix
- $objNode
- $objPreviousItemArray
- $strColumnAliasArray
Returns
boolean|null Returns true if the we used the row for an expansion, false if we already expanded this node in a previous row, or null if no expansion data was found
|
public static
null|object
|
#
GetFromCache( $key )
Return an object corresponding to the given key, or null.
Return an object corresponding to the given key, or null.
The key might be null if: The table has no primary key, or SetSkipPrimaryKey was used in a query with QSelect.
Otherwise, the default here is to use the local cache.
Note that you rarely would want to change this. Caching at this level happens
after a query has executed. Using a cache like APC or MemCache at this point would
be really expensive, and would only be worth it for a large table.
Parameters
Returns
null|object
|
public
|
#
WriteToCache( )
Put the current object in the cache for future reference.
Put the current object in the cache for future reference.
|
public
|
#
DeleteFromCache( )
Delete this particular object from the cache
Delete this particular object from the cache
|
public static
|
#
ClearCache( )
Clears the caches associated with this table.
Clears the caches associated with this table.
|