abstract class Engine

Engine provides generic support for databases.

The class will have to be extended by completing the particularities of each of them.

Properties

static DebugTool $debugTool The debug tool used.
static array $dbStructure Contains the database structure data.
static protected string $dsn Data Source Name
static protected array $dbConfig Array that contains the access data to the database.
static protected PDO $dbHandler The handler of the database.
static protected PDOStatement|bool $statement Represents a prepared statement and, after the statement is executed, an associated result set.
static protected bool $savePointsSupport True if the database engine supports SAVEPOINT in transactions
static protected int $transactionDepth Number of transactions in execution
static protected PDOCollector $pdoCollector PDO Data collector.
static protected PDO $pdo Connection between PHP and a database server.

Methods

__construct(array $dbConfig)

Engine constructor

static array
getEngines()

Return a list of available database engines.

static array
unsupportedEngines()

Returns a list of unsupported engines.

static array
getStructure(string $tableName, bool $usePrefix = true)

Obtain an array with the table structure with a standardized format.

static bool
batchExec(array $queries)

Execute SQL statements on the database (INSERT, UPDATE or DELETE).

static bool
exec(string $query, array $vars = [])

Prepare and execute the query.

static array
selectCoreCache(string $cachedName, string $query, array $vars = [])

Executes a SELECT SQL statement on the core cache.

static array
select(string $query, array $vars = [])

Executes a SELECT SQL statement on the database, returning the result in an array.

static bool
clearCoreCache(string $cachedName)

Clear item from cache.

__destruct()

Engine destructor

rollBackTransactions()

Undo all active transactions

bool
rollBack()

Rollback current transaction,

string
getLastInserted()

Returns the id of the last inserted record. Failing that, it returns ''.

bool
checkConnection()

Returns if a database connection exists or not.

bool
connect(array $config = [])

Establish a connection to the database.

bool
prepare(string $sql, array $options = [])

Prepares a statement for execution and returns a statement object

array
resultSet()

Returns an array containing all of the result set rows

bool
execute(array $inputParameters = [])

Executes a prepared statement

bool
beginTransaction()

Start transaction

bool
commit()

Commit current transaction

array
getDbStructure()

Returns database structure.

mixed
getDbTableStructure(string $tablename)

Returns database table structure.

bool
issetDbTableStructure(string $tablename)

Returns if table is set to database structure.

bool
issetDbTableStructureKey(string $tablename, string $key)

Returns if key is set to database structure.

setDbTableStructure(string $tablename, array $data)

Sets database structure for a tablename.

Details

at line 105
__construct(array $dbConfig)

Engine constructor

Parameters

array $dbConfig

at line 122
static array getEngines()

Return a list of available database engines.

Return Value

array

at line 147
static array unsupportedEngines()

Returns a list of unsupported engines.

The unsupported engines here are the not fully supported yet.

Return Value

array

at line 161
static array getStructure(string $tableName, bool $usePrefix = true)

Obtain an array with the table structure with a standardized format.

Parameters

string $tableName
bool $usePrefix

Return Value

array

at line 176
final static bool batchExec(array $queries)

Execute SQL statements on the database (INSERT, UPDATE or DELETE).

Parameters

array $queries

Return Value

bool

at line 197
final static bool exec(string $query, array $vars = [])

Prepare and execute the query.

Parameters

string $query
array $vars

Return Value

bool

at line 221
final static array selectCoreCache(string $cachedName, string $query, array $vars = [])

Executes a SELECT SQL statement on the core cache.

Parameters

string $cachedName
string $query
array $vars

Return Value

array

at line 256
static array select(string $query, array $vars = [])

Executes a SELECT SQL statement on the database, returning the result in an array.

In case of failure, return NULL. If there is no data, return an empty array.

Parameters

string $query
array $vars

Return Value

array

at line 274
final static bool clearCoreCache(string $cachedName)

Clear item from cache.

Parameters

string $cachedName

Return Value

bool

at line 290
__destruct()

Engine destructor

at line 298
private rollBackTransactions()

Undo all active transactions

at line 310
final bool rollBack()

Rollback current transaction,

Return Value

bool

at line 337
final string getLastInserted()

Returns the id of the last inserted record. Failing that, it returns ''.

Return Value

string

at line 351
bool checkConnection()

Returns if a database connection exists or not.

Return Value

bool

at line 365
bool connect(array $config = [])

Establish a connection to the database.

If a connection already exists, it returns it. It does not establish a new one. Returns true in case of success, assigning the handler to self::$dbHandler.

Parameters

array $config

Return Value

bool

at line 401
final bool prepare(string $sql, array $options = [])

Prepares a statement for execution and returns a statement object

Parameters

string $sql
array $options

Return Value

bool

at line 417
final array resultSet()

Returns an array containing all of the result set rows

Return Value

array

at line 432
final bool execute(array $inputParameters = [])

Executes a prepared statement

Parameters

array $inputParameters

Return Value

bool

at line 449
final bool beginTransaction()

Start transaction

Return Value

bool

at line 471
final bool commit()

Commit current transaction

Return Value

bool

at line 494
final array getDbStructure()

Returns database structure.

Return Value

array

at line 506
final mixed getDbTableStructure(string $tablename)

Returns database table structure.

Parameters

string $tablename

Return Value

mixed

at line 518
final bool issetDbTableStructure(string $tablename)

Returns if table is set to database structure.

Parameters

string $tablename

Return Value

bool

at line 531
final bool issetDbTableStructureKey(string $tablename, string $key)

Returns if key is set to database structure.

Parameters

string $tablename
string $key

Return Value

bool

at line 542
final setDbTableStructure(string $tablename, array $data)

Sets database structure for a tablename.

Parameters

string $tablename
array $data