Home  Support  API

EntityQuery Class Reference
[Query]


LINQ to OrmEntity.

Example:

 $entitySet =
    EntityQuery::create(MyEntity::orm())
        ->where(
            Expression::between(
                'time',
                Date::create('-1 day')
                Date::create('+1 day')
            )
        )
        ->getList();

API to fill the query:

API to retrieve ORM-related entity objects:

API to retrieve raw data:

Definition at line 54 of file EntityQuery.class.php.

Inheritance diagram for EntityQuery:
Inheritance graph

List of all members.

Static Public Member Functions

static create (IQueryable $entity)
 EntityQuery static constructor.

Public Member Functions

 __clone ()
 __construct (IQueryable $entity)
 addProjection (IProjection $projection)
 Appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.
 andWhere (IExpression $condition)
 Joins the condition for rows that should be selected using conjunction.
 delete ()
 Performs a deletion of persisten objects.
 dropProjection ()
 Drops the projection chain.
 get (IProjection $projection)
 Appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.
 getCell ()
 Gets the plain database tuple cell.
 getCount ()
 Gets the number of entities presented in the database according to the current setting of EntityQuery.
 getEntity ()
 Gets the ORM-related entity object.
 getList ()
 Gets the set plain database tuples.
 getPlaceholderValues (IDialect $dialect)
 Gets the database values that should be mapped to database-level placeholers that are presented in a query.
 getProperty ($property)
 Gets the value of the entity's property.
 getQueryRoot ()
 Gets the entity we are going to query.
 getRow ()
 Gets the plain database tuple.
 getRows ()
 Gets a set of tuples of raw database values.
 orderBy ()
 Appends the list of expressions that will be used when sorting the resulting rows.
 orWhere (IExpression $condition)
 Joins the condition for rows that should be selected using disjunction.
 setDistinct ()
 Sets the query to eliminate duplicate rows from the result.
 setLimit ($limit)
 Sets the maximum number of rows to return.
 setOffset ($offset)
 Sets the number of rows to skip before starting to return rows.
 setProjection (IProjection $projection)
 Cleans the projection chain and appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.
 toDialectString (IDialect $dialect)
 Represents the object as unified SQL string.
 toExpression ()
 Converts EntityQuery to IExpresion object.
 toSelectQuery ()
 Presents EntityQuery as SelectQuery object.
 where (IExpression $condition)
 Sets the condition for rows that should be selected.

Constructor & Destructor Documentation

EntityQuery::__construct ( IQueryable entity  ) 
Parameters:
IQueryable $entity entity we are going to query

Definition at line 104 of file EntityQuery.class.php.


Member Function Documentation

EntityQuery::__clone (  ) 

Definition at line 111 of file EntityQuery.class.php.

EntityQuery::addProjection ( IProjection projection  ) 

Appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.

Example:

 // gets the number of entities within the database
 $count =
    EntityQuery::create(MyEntry::orm())
        ->get(Projection::rowCount())
        ->getCell();
Parameters:
IProjection ...
Returns:
EntityQuery itlsef

Definition at line 223 of file EntityQuery.class.php.

EntityQuery::andWhere ( IExpression condition  ) 

Joins the condition for rows that should be selected using conjunction.

Only rows for which this expression returns true will be selected.

Parameters:
IExpression $condition condition to be applied when selected rows
Returns:
EntityQuery

Definition at line 290 of file EntityQuery.class.php.

References Expression::conjunction().

static EntityQuery::create ( IQueryable entity  )  [static]
EntityQuery::delete (  ) 

Performs a deletion of persisten objects.

Returns:
int

Definition at line 403 of file EntityQuery.class.php.

References toExpression().

EntityQuery::dropProjection (  ) 

Drops the projection chain.

Definition at line 258 of file EntityQuery.class.php.

Referenced by setProjection().

EntityQuery::get ( IProjection projection  ) 

Appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.

Example:

 // gets the number of entities within the database
 $count =
    EntityQuery::create(MyEntry::orm())
        ->get(Projection::rowCount())
        ->getCell();
Parameters:
IProjection ...
Returns:
EntityQuery itlsef

Definition at line 196 of file EntityQuery.class.php.

EntityQuery::getCell (  ) 

Gets the plain database tuple cell.

The cell is obtained according to the current setting of EntityQuery and the FetchStrategy set inside DAO of the entity

Returns:
scalar

Definition at line 449 of file EntityQuery.class.php.

EntityQuery::getCount (  ) 

Gets the number of entities presented in the database according to the current setting of EntityQuery.

Returns:
int

Definition at line 469 of file EntityQuery.class.php.

References Projection::rowCount().

EntityQuery::getEntity (  ) 

Gets the ORM-related entity object.

The object is obtained according to the current setting of EntityQuery and the FetchStrategy set inside DAO of the entity

Returns:
IdentifiableOrmEntity

Definition at line 419 of file EntityQuery.class.php.

EntityQuery::getList (  ) 

Gets the set plain database tuples.

The tuples are obtained according to the current setting of EntityQuery and the FetchStrategy set inside DAO of the entity

Returns:
array

Definition at line 459 of file EntityQuery.class.php.

EntityQuery::getPlaceholderValues ( IDialect dialect  ) 

Gets the database values that should be mapped to database-level placeholers that are presented in a query.

This can be extremely useful when using database placeholders and query preparation over high-load DB servers with persistent connections.

Returns:
array of scalar

Implements ISqlQuery.

Definition at line 493 of file EntityQuery.class.php.

EntityQuery::getProperty ( property  ) 

Gets the value of the entity's property.

The value is obtained according to the current setting of EntityQuery and the FetchStrategy set inside DAO of the entity

Parameters:
string name of the property
Returns:
scalar

Definition at line 484 of file EntityQuery.class.php.

References Projection::property().

EntityQuery::getQueryRoot (  ) 

Gets the entity we are going to query.

Returns:
IQueryable

Definition at line 124 of file EntityQuery.class.php.

Referenced by Container::setQuery().

EntityQuery::getRow (  ) 

Gets the plain database tuple.

The tuple is obtained according to the current setting of EntityQuery and the FetchStrategy set inside DAO of the entity

Returns:
associative array that represents a tuple of raw database values

Definition at line 429 of file EntityQuery.class.php.

EntityQuery::getRows (  ) 

Gets a set of tuples of raw database values.

Returns:
array of associative arrays that represent a tuples of raw database values

Definition at line 439 of file EntityQuery.class.php.

EntityQuery::orderBy (  ) 

Appends the list of expressions that will be used when sorting the resulting rows.

Multiple arguments implementing OrderBy are accepted.

We don't know why OrderBY is not a part of a separate projection, so we follow the default behaviour of nhibernate

Parameters:
OrderBy ...
Returns:
EntityQuery itself

Definition at line 151 of file EntityQuery.class.php.

EntityQuery::orWhere ( IExpression condition  ) 

Joins the condition for rows that should be selected using disjunction.

Only rows for which this expression returns true will be selected.

Parameters:
IExpression $condition condition to be applied when selected rows
Returns:
EntityQuery

Definition at line 311 of file EntityQuery.class.php.

References Expression::disjunction().

EntityQuery::setDistinct (  ) 

Sets the query to eliminate duplicate rows from the result.

Returns:
EntityQuery itself

Definition at line 133 of file EntityQuery.class.php.

EntityQuery::setLimit ( limit  ) 

Sets the maximum number of rows to return.

Parameters:
integer $limit positive integer
Returns:
ISqlSelectQuery itself

Implements ISqlSelectQuery.

Definition at line 161 of file EntityQuery.class.php.

References Assert::isPositiveInteger().

EntityQuery::setOffset ( offset  ) 

Sets the number of rows to skip before starting to return rows.

Parameters:
integer $offset positive integer
Returns:
ISqlSelectQuery itself

Implements ISqlSelectQuery.

Definition at line 170 of file EntityQuery.class.php.

References Assert::isPositiveInteger().

EntityQuery::setProjection ( IProjection projection  ) 

Cleans the projection chain and appends an IProjection object to the projection chain that actually makes a selection expression that form the output rows of the statement.

Example:

 // gets the number of entities within the database
 $count =
    EntityQuery::create(MyEntry::orm())
        ->get(Projection::rowCount())
        ->getCell();
Parameters:
IProjection ...
Returns:
EntityQuery itlsef

Definition at line 248 of file EntityQuery.class.php.

References dropProjection().

EntityQuery::toDialectString ( IDialect dialect  ) 

Represents the object as unified SQL string.

Parameters:
IDialect $dialect
Returns:
string

Implements ISqlCastable.

Definition at line 498 of file EntityQuery.class.php.

References toSelectQuery().

EntityQuery::toExpression (  ) 

Converts EntityQuery to IExpresion object.

Note that projections, and references to associated entities are useless and won't be presented in the resulting expression because required joins can only be specified as sources for selection

Todo:
check whether we refer to encapsulants and avoid this
Returns:
IExpression

Definition at line 380 of file EntityQuery.class.php.

References Assert::isTrue().

Referenced by delete().

EntityQuery::toSelectQuery (  ) 

Presents EntityQuery as SelectQuery object.

Returns:
SelectQuery

Definition at line 328 of file EntityQuery.class.php.

References Projection::entity().

Referenced by toDialectString().

EntityQuery::where ( IExpression condition  ) 

Sets the condition for rows that should be selected.

Only rows for which this expression returns true will be selected.

Parameters:
IExpression $condition condition to be applied when selected rows
Returns:
EntityQuery

Definition at line 274 of file EntityQuery.class.php.


The documentation for this class was generated from the following file: