Jet\DataModel_Query

The class represents query either the whole SELECT query or the WHERE part of UPDATE and DELETE queries - the class is common for both options, the only difference is how it is used.

Overview of methods

Method Meaning of
public static createQuery(
DataModel_Definition_Model $main_data_model_definition,
array $where=[]
) : DataModel_Query
The static method creates and presets an instance representing a query which is bound to a specific entity.
public __construct(
DataModel_Definition_Model $main_data_model_definition
)
The constructor needs to know the definition of the entity that the query will primarily refer to.
public getDataModelDefinition(
) : DataModel_Definition_Model
Returns the definition of the entity to be queried primarily.
public getSelect(
) : DataModel_Query_Select|null
Returns an instance of the SELECT part of the query definition.
public setSelect(
array $items
) : DataModel_Query|null
Sets the SELECT part of the query. See query creation.
public getWhere(
) : DataModel_Query_Where|null
Returns an instance of the WHERE part of the query definition.
public setWhere(
array $where
) : DataModel_Query
Sets the WHERE part of the query. See query creation.
public getHaving(
) : DataModel_Query_Having|null
Returns an instance of the HAVING part of the query definition.
public setHaving(
array $having
) : DataModel_Query
Sets the HAVING part of the query. See query creation.
public getGroupBy(
) : DataModel_Query_GroupBy|null
Returns an instance of the GROUP BY definition part of the query.
public setGroupBy(
array|string $group_by
) : DataModel_Query
Sets the GROUP BY part of the query. See query creation.
public getOrderBy(
) : DataModel_Query_OrderBy|null
Returns an instance of the ORDER BY part of the query definition.
public setOrderBy(
array|string $order_by
) : DataModel_Query
Sets the ORDER BY part of the query. See query creation.
public setLimit(
int $limit,
?int $offset=null
) : DataModel_Query
Sets the limit and offset (optional) for loading data. De facto enables the paging mode of SELECT queries.
public getLimit(
) : int|null
Returns the set limit for reading data.
public getOffset(
) : int|null
Returns the set offset for reading data.
public getRelations(
) : DataModel_Definition_Relation[]
Returns the definitions of all relations that will be relevant to the SELECT query.
public addRelation(
string $name,
DataModel_Definition_Relation $relation
) : void
Adds a relation to the query definition.
public setRelationJoinType(
string $related_data_model_name,
string $join_type
) : DataModel_Query
Sets the type of relation used in the SELECT query.
public getRelation(
string $related_data_model_name
) : DataModel_Definition_Relation
Returns the relation definition for a specific entity within a SELECT query.
public getPropertyAndSetRelation(
string $property_name
) : DataModel_Definition_Property
Returns the definition of the property used in the query, and if the property is not related to the primary entity bound to the query, it finds and sets a relation to the subentity or entity bound by an external relation.
public setRawMode(
bool $raw_mode
): void
Defines whether to override the ORM check of record data types after records are read from the database. If true, the data is returned as read by the database without further transformation. Useful for processing large amounts of data.
public getRawMode(
): bool
Indicates whether to override ORM checking of record data types after records are retrieved from the database. If true, the data is returned as read by the database without further transformation. Useful for processing large amounts of data.
public toString(
) : string
The definition is converted by the backend into a real query (text string) of the SELECT type corresponding to the given database type.
public __toString(
) : string
The definition is converted by the backend into a real query (text string) of the SELECT type corresponding to the given database type.
Previous chapter
Jet\DataModel_PropertyFilter
Next chapter
Jet\DataModel_Query_Select