Jet\DataModel

The base abstract class from which all entities inherit.

Overview of methods

Method Meaning of
public static getDataModelDefinition(
string $class_name=''
) : DataModel_Definition_Model
Static method that returns the definition of the entity.

It can be used in two ways:

Be in direct context with the class:
$definition SomeEntity::getDataModelDefinition();
Or in a general context:
$definition DataModel::getDataModelDefinitionSomeEntity::class );
public static dataModelDefinitionType(
) : string
The static method returns what type of entity it is: $type SomeEntity::dataModelDefinitionType(); Returns one of the following constants:
  • DataModel::MODEL_TYPE_MAIN
  • DataModel::MODEL_TYPE_RELATED_1TON
  • DataModel::MODEL_TYPE_RELATED_1TO1
public getIDController(
) : DataModel_IDController
Returns the controller ID instance linked to the entity instance.
public static getEmptyIDController(
) : DataModel_IDController
Returns a generic unconnected instance of controller ID.
public setIsNew(
) : void
Sets the internal state so that the object is considered new - not yet saved. So when saving, the insert action will be performed instead of the update action. It is useful for example when cloning.

Warning! The method only sets the internal state. It does not reset IDs and such - that is a matter of your application logic.
public getIsNew(
) : bool
Indicates whether the object is considered new - not yet saved.
public getIsSaved(
) : bool
Indicates whether the object is considered already stored.
public setIsSaved(
) : void
Sets the object to the "saved" state. Thus, the next time the object is saved, an update operation will be performed. Primarily intended for internal purposes.
public static getBackendInstance(
) : DataModel_Backend
Returns a prepared instance of backend based on the definition.
public startBackendTransaction(
) : void
The method is primarily used internally. As the name suggests, it initiates a transaction during modification operations (save, delete).
public getBackendTransactionStarted(
) : bool
The method is primarily used internally. It induces whether the transaction has already been started.
public commitBackendTransaction(
) : void
The method is primarily used internally. It terminates and sends the transaction.
public getBackendTransactionStartedByThisInstance(
) : bool
The method is primarily used internally. It induces whether the transaction has already been started by the object (the instance that calls the method).
public rollbackBackendTransaction(
) : void
The method is primarily used internally. It cancels and reverts the transaction.
public getLoadFilter(
) : DataModel_PropertyFilter|null
Indicates whether restricted loading mode is active, and if so, returns an instance of the restriction rule definition.
public static createQuery(
array $where=[]
) : DataModel_Query
Creates a generic instance of the query definition. Primarily an internal method.
public static initByData(
array $this_data,
array $related_data=[],
DataModel_PropertyFilter $load_filter=null
) : static
Internal method used during loading. It is used to create instances of entities based on data read from the database.
public static load(
array|string|int|DataModel_IDController $id_or_where,
array|DataModel_PropertyFilter|null $load_filter=null
) : static|null
It is used to read one specific instance of an entity.
public static fetch(
array $where_per_model=[],
array|string|null $order_by=null,
?callable $item_key_generator=null,
array|DataModel_PropertyFilter|null $load_filter=null
) : array
It is used for low-level reading of multiple entity instances.
public static dataFetchAll(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
It is used for low-level reading of raw data - not entity instances.

Simple loading of all data.
public static dataFetchAssoc(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
It is used for low-level reading of raw data - not entity instances.

The first property will be taken as the key of the resulting list array.
public static dataFetchCol(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
It is used for low-level reading of raw data - not entity instances.

The result will be a simple one-dimensional array consisting of the first recorded entity property.
public static dataFetchPairs(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
Used for low-level reading of raw data - not entity instances.

Returns an associated array where the key is the first specified property and the value is the second.
public static dataFetchRow(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
Used for low-level reading of raw data - not entity instances.

Returns only one row.
public static dataFetchOne(
array $select,
array $where,
null|array|string $group_by = null,
null|array $having = null,
null|string|array $order_by=null,
null|int $limit=null,
null|int $offset=null
) : mixed
Slouží k nízkoúrovňovému načtení surových dat - nikoliv instancí entit.

Vrátí pouze jednu hodnotu.
public static fetchInstances(
array $where=[],
array $load_filter=[]
) : DataModel_Fetch_Instances
It is used to indirectly read via the iterator Jet\DataModel_Fetch_Instances.
public static fetchIDs(
array $where=[]
) : DataModel_Fetch_IDs
It is used to indirectly read a list of IDs via the iterator Jet\DataModel_Fetch_IDs.
public save(
) : void
Enter the entity into the database.
public static updateData(
array $data,
array $where
) : void
Update partial entity data in the database.
public delete(
) : void
Delete an entity record.
public dataDelete(
array $where
) : void
Delete a specific record or records from the database table.
public toJSON(
) : string
Export entities to JSON formats.
public jsonSerialize(
) : array
Export an entity to JSON format. The entity can be passed to the json_encode function.
public afterLoad(
) : void
See events
public beforeSave(
) : void
See events
public afterAdd(
) : void
See events
public afterUpdate(
) : void
See events
public afterDelete(
) : void
See events
Previous chapter
In depth
Next chapter
Jet\DataModel_Related