Jet\DataModel_Backend

The default abstract class that is common to every backend.

Method overview - general methods for working with backends

Method Meaning of
public static addBackendType(
string $type,
string $class_name,
string $config_class_name
) : void
It is possible to add a completely new type of backend that Jet does not support by default.

The method will also provide factory settings.

The appropriate place for such a call is the initialization script ~/application/Init/Factory.php

Parameters:
  • $type
    Type identifier.
  • $class_name
    The name of the backend class itself.
  • $config_class_name
    The class name of the configuration definition of the backend.
public static getAllBackendTypes(
) : array
Returns a list of all known backends as an array of type identifiers.
public static getAvlBackendTypes(
) : array
Returns a list of backends usable on the given system (e.g. depending on whether PHP has the necessary modules installed) in the form of an array of type identifiers.
public static getMainConfig(
) : DataModel_Config
Vrátí instanci singletonu hlavní konfigurace.
public static getDefaultBackendType(
) : string
Returns the identifier of the default backend type. This is an alias call: self::getMainConfig()->getBackendType();
public static getDefaultBackend(
) : DataModel_Backend
Returns an instance of the default backend.
public static setDefaultBackend(
DataModel_Backend $default_backend
) : void
Sets the default backend instance.
public static get(
DataModel_Definition_Model $definition
) : DataModel_Backend
Returns a backend instance for a specific entity (see below) based on its definition.
public static setCustomBackend(
string $data_model_class_name,
DataModel_Backend $backend
) : void
It is possible to set a special backend instance for a specific class - entity. Maybe even a completely different type than the default backend, or just with different settings.
public static getCustomBackend(
string $data_model_class_name
) : DataModel_Backend|null
See the setCustomBackend method.

If a special backend instance is set for the entity, then it returns it.
public static unsetCustomBackend(
string $data_model_class_name
) : DataModel_Backend
See the setCustomBackend method.

Unset a special instance of the backend for the entity.

Overview of methods - methods of the backend itself

Method Meaning of
public __construct(
?DataModel_Backend_Config $config=null
)
The only parameter is the backend configuration instance.
public getType(
) : string
Returns the backend type identifier.
public getTitle(
) : string
Returns the title of the backend - a human-readable title.
public isAvailable(
) : bool
Indicates whether the backend can be used on the given system and configuration.
public prepareDefaultDbConnectionConfig(
) : ?Db_Backend_Config
It can preconfigure the database connection. Useful for tools like the installer.
public createSelectQuery(
DataModel_Query $query
) : string
Creates a SELECT query based on the query definition.
public createCountQuery(
DataModel_Query $query
) : string
Based on the query definition, it creates a SELECT query to determine the number of records.
public createInsertQuery(
DataModel_RecordData $record
) : string
Based on the set of data to be stored, it creates a query of the INSERT type.
public createUpdateQuery(
DataModel_RecordData $record,
DataModel_Query $where
) : string
Based on the data set to be stored and the query (its WHERE part), it creates a query of the UPDATE type.
public createDeleteQuery(
DataModel_Query $where
$where
) : string
Based on the query definition (its WHERE part), it creates a DELETE query.
public save(
DataModel_RecordData $record
) : mixed
Saves the dataset as a new record.
public update(
DataModel_RecordData $record,
DataModel_Query $where
$where
) : int
Upraví sadu dat podle dotazu (jeho WHERE části) a vrátí počet ovlivněných záznamů.
public delete(
DataModel_Query $where
$where
) : int
Based on the query (its WHERE part), it deletes records and returns the number of records actually deleted.
public getCount(
DataModel_Query $query
) : int
Determines how many items the result of the SELECT query will have.
public fetchAll(
DataModel_Query $query
) : mixed
Executes a SELECT query based on the definition.

Simple load of all data.
public fetchAssoc(
DataModel_Query $query
) : mixed
Performs a SELECT query based on the definition.

The first property will be taken as the key of the result list array.
public fetchPairs(
DataModel_Query $query
) : mixed
Performs a SELECT query based on the definition.

Returns an associated array where the key is the first specified property and the value is the second.
public fetchRow(
DataModel_Query $query
) : mixed
Performs a SELECT query based on the definition.

Returns only one row.
public fetchOne(
DataModel_Query $query
) : mixed
Performs a SELECT query based on the definition.

Returns only one value.
public fetchCol(
DataModel_Query $query
) : mixed
Performs a SELECT query based on the definition.

The result will be a simple one-dimensional array consisting of the first recorded entity property.
public transactionStart(
) : void
Transaction start
public getTransactionStarted(
) : bool
Indicates whether the transaction has already started.
public getTransactionStarter(
) : DataModel|null
If the transaction has already been initiated, it returns the instance of the entity that initiated it.
public setTransactionStarter(
?DataModel $transaction_starter
) : void
Sets the instance of the entity that initiated the transaction.
public transactionCommit(
) : void
Sends a successfully completed transaction.
public transactionRollback(
) : void
Rollback a failed transaction.
protected validateResultData(
DataModel_Query $query,
string $fetch_method,
array $data
) : array
Converts the raw data from the query result to the correct types according to the definition.
protected unserialize(
string $string
) : mixed
Unserialize data.
protected serialize(
mixed $data
) : string
Serialize data.
public helper_tableExists(
DataModel_Definition_Model $definition
) : bool
Determines whether the corresponding database table already exists.
public helper_getCreateCommand(
DataModel_Definition_Model $definition,
?string $force_table_name=null
) : string
Returns a command to create a database table for the given class - usually SQL code.
public helper_create(
DataModel_Definition_Model $definition
) : void
Creates a database table of the given class according to the definition.
public helper_getDropCommand(
DataModel_Definition_Model $definition
) : string
Returns a command to drop database table.
public helper_drop(
DataModel_Definition_Model $definition
) : void
Drop database table of the given class.
public helper_getUpdateCommand(
DataModel_Definition_Model $definition
) : array
Returns a set of statements designed to update the database table of the class according to the current definition.
public helper_update(
DataModel_Definition_Model $definition
) : void
Updates the database table of the given class according to the current definition.
Previous chapter
Jet\DataModel_Config
Next chapter
Jet\DataModel_Backend_Config