|
Ubiquity 2.5.2
php rapid development framework
|
Ubiquity Generic database class. More...
Inheritance diagram for Database:Public Member Functions | |
| __construct ($dbWrapperClass, $dbType, $dbName, $serverName="127.0.0.1", $port="3306", $user="root", $password="", $options=[], $cache=false, $pool=null) | |
| Constructor. | |
| connect () | |
| Creates the Db instance and realize a safe connection. | |
| getDSN () | |
| getServerName () | |
| setServerName ($serverName) | |
| setDbType ($dbType) | |
| getPort () | |
| getDbName () | |
| getUser () | |
| getDbType () | |
| getPassword () | |
| getOptions () | |
| setPort ($port) | |
| setDbName ($dbName) | |
| setUser ($user) | |
| setPassword ($password) | |
| setOptions ($options) | |
| close () | |
| Closes the active connection. | |
| quoteValue ($value, $type=2) | |
| getUpdateFieldsKeyAndValues ($keyAndValues, $fields) | |
| getInsertValues ($keyAndValues) | |
| getCondition (array $keyValues, $separator=' AND ') | |
| pool () | |
| For databases with Connection pool (retrieve a new dbInstance from pool wrapper) | |
| freePool ($db) | |
| For databases with Connection pool (put a dbInstance in pool wrapper) | |
| setPool ($pool) | |
| getSpecificSQL ($key, ?array $params=null) | |
| setCacheInstance (DbCache $cache) | |
| getCacheInstance () | |
Public Member Functions inherited from DatabaseOperationsTrait | |
| getDbObject () | |
| _connect () | |
| query ($sql) | |
| Executes an SQL statement, returning a result set as a statement object. | |
| prepareAndExecute ($tableName, $condition, $fields, $parameters=null, $useCache=false, $one=false) | |
| _optExecuteAndFetch ($statement, $tableName, $condition, $parameters=null, $useCache=false, $one=false) | |
| _optExecuteAndFetchNoCache ($statement, $parameters=null, $one=false) | |
| getDaoPreparedStatement ($tableName, $condition, $fields) | |
| prepareAndExecuteNoCache ($tableName, $condition, $fields, $parameters=null) | |
| storeCache () | |
| prepareAndFetchAll ($sql, $parameters=null, $mode=null) | |
| prepareAndFetchOne ($sql, $parameters=null, $mode=null) | |
| prepareAndFetchAllColumn ($sql, $parameters=null, $column=null) | |
| prepareAndFetchColumn ($sql, $parameters=null, $columnNumber=0) | |
| getUpdateStatement ($sql) | |
| prepareAndExecuteUpdate ($sql, $parameters=null) | |
| Prepares a statement and execute a query for update (INSERT, UPDATE, DELETE...) | |
| execute ($sql) | |
| Execute an SQL statement and return the number of affected rows (INSERT, UPDATE or DELETE) | |
| prepareStatement ($sql) | |
| Prepares a statement for execution and returns a statement object. | |
| prepareNamedStatement (string $name, string $sql) | |
| Prepares and returns a statement for execution and gives it a name. | |
| getNamedStatement (string $name, ?string $sql=null) | |
| Returns the statement corresponding to the name. | |
| bindValueFromStatement ($statement, $parameter, $value) | |
| Sets $value to $parameter. | |
| lastInserId ($name=null) | |
| Returns the last insert id. | |
| count ($tableName, $condition='') | |
| Returns the number of records in $tableName matching with the condition passed as a parameter. | |
| queryColumn ($query, $columnNumber=null) | |
| fetchAll ($query, $mode=null) | |
| isConnected () | |
| ping () | |
Public Member Functions inherited from DatabaseTransactionsTrait | |
| beginTransaction () | |
| Initiates a transaction. | |
| commit () | |
| Commits a transaction. | |
| commitToLevel ($transactionLevel) | |
| Commits nested transactions up to level $transactionLevel. | |
| commitAll () | |
| Commits all nested transactions (up to level 0) | |
| rollBack () | |
| Rolls back a transaction. | |
| rollBackToLevel ($transactionLevel) | |
| Rolls back nested transactions up to level $transactionLevel. | |
| rollBackAll () | |
| Rolls back all nested transactions (up to level 0) | |
| inTransaction () | |
| Checks if inside a transaction. | |
| callInTransaction ($callback,... $parameters) | |
| Call a callback with an array of parameters in a transaction. | |
| setIsolationLevel ($isolationLevel) | |
| Sets the isolation level for transactions. | |
Public Member Functions inherited from DatabaseMetadatas | |
| getTablesName () | |
| getPrimaryKeys ($tableName) | |
| getFieldsInfos ($tableName) | |
| getForeignKeys ($tableName, $pkName, $dbName=null) | |
| getRowNum (string $tableName, string $pkName, string $condition) | |
| getPHPType (string $dbType) | |
| migrateOperation (string $operation) | |
| Returns the SQL command for a migration operation. | |
Static Public Member Functions | |
| static | getAvailableDrivers ($dbWrapperClass=\Ubiquity\db\providers\pdo\PDOWrapper::class) |
| static | start (string $offset=null, ?array $config=null) |
| Starts and returns a database instance corresponding to an offset in config. | |
| static | getAvailableWrappers () |
Data Fields | |
| $quote | |
Static Public Attributes | |
| static | $wrappers = [ 'pdo' => \Ubiquity\db\providers\pdo\PDOWrapper::class,'tarantool' => '\Ubiquity\db\providers\tarantool\TarantoolWrapper','mysqli' => '\Ubiquity\db\providers\mysqli\MysqliWrapper','swoole' => '\Ubiquity\db\providers\swoole\SwooleWrapper' ] |
Protected Attributes | |
| $wrapperObject | |
Protected Attributes inherited from DatabaseTransactionsTrait | |
| $transactionLevel = 0 | |
Private Member Functions | |
| setDbWrapperClass ($dbWrapperClass, $dbType) | |
Private Attributes | |
| $dbType | |
| $serverName | |
| $port | |
| $dbName | |
| $user | |
| $password | |
| $cache | |
| $options | |
Additional Inherited Members | |
Protected Member Functions inherited from DatabaseTransactionsTrait | |
| nestable () | |
Ubiquity Generic database class.
Ubiquity\db$Database This class is part of Ubiquity
Definition at line 25 of file Database.php.
| __construct | ( | $dbWrapperClass, | |
| $dbType, | |||
| $dbName, | |||
$serverName = "127.0.0.1", |
|||
$port = "3306", |
|||
$user = "root", |
|||
$password = "", |
|||
$options = [ ], |
|||
$cache = false, |
|||
$pool = null |
|||
| ) |
Constructor.
| string | $dbWrapperClass | |
| string | $dbName | |
| string | $serverName | |
| string | $port | |
| string | $user | |
| string | $password | |
| array | $options | |
| boolean | string | $cache | |
| mixed | $pool |
Definition at line 57 of file Database.php.
| close | ( | ) |
Closes the active connection.
Definition at line 224 of file Database.php.
| connect | ( | ) |
Creates the Db instance and realize a safe connection.
| DBException |
Definition at line 91 of file Database.php.
| freePool | ( | $db | ) |
For databases with Connection pool (put a dbInstance in pool wrapper)
Definition at line 284 of file Database.php.
|
static |
Definition at line 150 of file Database.php.
|
static |
Definition at line 292 of file Database.php.
| getCacheInstance | ( | ) |
Definition at line 315 of file Database.php.
| getCondition | ( | array | $keyValues, |
$separator = ' AND ' |
|||
| ) |
Definition at line 266 of file Database.php.
| getDbName | ( | ) |
Definition at line 137 of file Database.php.
| getDbType | ( | ) |
Definition at line 159 of file Database.php.
| getDSN | ( | ) |
Reimplemented from DatabaseOperationsTrait.
Definition at line 101 of file Database.php.
| getInsertValues | ( | $keyAndValues | ) |
Definition at line 258 of file Database.php.
| getOptions | ( | ) |
Definition at line 177 of file Database.php.
| getPassword | ( | ) |
Definition at line 168 of file Database.php.
| getPort | ( | ) |
Definition at line 128 of file Database.php.
| getServerName | ( | ) |
Definition at line 110 of file Database.php.
| getSpecificSQL | ( | $key, | |
| ?array | $params = null |
||
| ) |
Definition at line 302 of file Database.php.
| getUpdateFieldsKeyAndValues | ( | $keyAndValues, | |
| $fields | |||
| ) |
Definition at line 250 of file Database.php.
| getUser | ( | ) |
Definition at line 146 of file Database.php.
| pool | ( | ) |
For databases with Connection pool (retrieve a new dbInstance from pool wrapper)
Definition at line 277 of file Database.php.
| quoteValue | ( | $value, | |
$type = 2 |
|||
| ) |
Definition at line 246 of file Database.php.
| setCacheInstance | ( | DbCache | $cache | ) |
Definition at line 311 of file Database.php.
| setDbName | ( | $dbName | ) |
| string | $dbName |
Definition at line 193 of file Database.php.
| setDbType | ( | $dbType | ) |
Definition at line 118 of file Database.php.
|
private |
Definition at line 81 of file Database.php.
| setOptions | ( | $options | ) |
| array | $options |
Definition at line 217 of file Database.php.
| setPassword | ( | $password | ) |
| string | $password |
Definition at line 209 of file Database.php.
| setPool | ( | $pool | ) |
Definition at line 288 of file Database.php.
| setPort | ( | $port | ) |
| string | $port |
Definition at line 185 of file Database.php.
| setServerName | ( | $serverName | ) |
Definition at line 114 of file Database.php.
| setUser | ( | $user | ) |
| string | $user |
Definition at line 201 of file Database.php.
|
static |
Starts and returns a database instance corresponding to an offset in config.
| string | $offset | |
| array | $config | Ubiquity config file content |
Definition at line 235 of file Database.php.
|
private |
Definition at line 34 of file Database.php.
|
private |
Definition at line 31 of file Database.php.
|
private |
Definition at line 28 of file Database.php.
|
private |
Definition at line 35 of file Database.php.
|
private |
Definition at line 33 of file Database.php.
|
private |
Definition at line 30 of file Database.php.
| $quote |
Definition at line 36 of file Database.php.
|
private |
Definition at line 29 of file Database.php.
|
private |
Definition at line 32 of file Database.php.
|
protected |
Definition at line 42 of file Database.php.
|
static |
Definition at line 27 of file Database.php.