Ubiquity  2.3.2
php rapid development framework
Database Class Reference

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. More...
 
 connect ()
 Creates the Db instance and realize a safe connection. More...
 
 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. More...
 
 pool ()
 For databases with Connection pool (retrieve a new dbInstance from pool wrapper) More...
 
 freePool ($db)
 For databases with Connection pool (put a dbInstance in pool wrapper) More...
 
 setPool ($pool)
 
- Public Member Functions inherited from DatabaseOperationsTrait
 getDSN ()
 
 getDbObject ()
 
 _connect ()
 
 query ($sql)
 Executes an SQL statement, returning a result set as a statement object. More...
 
 prepareAndExecute ($tableName, $condition, $fields, $parameters=null, $useCache=NULL)
 
 prepareAndFetchAll ($sql, $parameters=null, $mode=null)
 
 prepareAndFetchOne ($sql, $parameters=null, $mode=null)
 
 prepareAndFetchAllColumn ($sql, $parameters=null, $column=null)
 
 prepareAndFetchColumn ($sql, $parameters=null, $columnNumber=null)
 
 getUpdateStatement ($sql)
 
 prepareAndExecuteUpdate ($sql, $parameters=null)
 Prepares a statement and execute a query for update (INSERT, UPDATE, DELETE...) More...
 
 execute ($sql)
 Execute an SQL statement and return the number of affected rows (INSERT, UPDATE or DELETE) More...
 
 prepareStatement ($sql)
 Prepares a statement for execution and returns a statement object. More...
 
 bindValueFromStatement ($statement, $parameter, $value)
 Sets $value to $parameter. More...
 
 lastInserId ()
 Returns the last insert id. More...
 
 count ($tableName, $condition='')
 Returns the number of records in $tableName matching with the condition passed as a parameter. More...
 
 queryColumn ($query, $columnNumber=null)
 
 fetchAll ($query, $mode=null)
 
 isConnected ()
 
 ping ()
 
- Public Member Functions inherited from DatabaseTransactionsTrait
 beginTransaction ()
 Initiates a transaction. More...
 
 commit ()
 Commits a transaction. More...
 
 commitToLevel ($transactionLevel)
 Commits nested transactions up to level $transactionLevel. More...
 
 commitAll ()
 Commits all nested transactions (up to level 0) More...
 
 rollBack ()
 Rolls back a transaction. More...
 
 rollBackToLevel ($transactionLevel)
 Rolls back nested transactions up to level $transactionLevel. More...
 
 rollBackAll ()
 Rolls back all nested transactions (up to level 0) More...
 
 inTransaction ()
 Checks if inside a transaction. More...
 
 callInTransaction ($callback,... $parameters)
 Call a callback with an array of parameters in a transaction. More...
 
- Public Member Functions inherited from DatabaseMetadatas
 getTablesName ()
 
 getPrimaryKeys ($tableName)
 
 getFieldsInfos ($tableName)
 
 getForeignKeys ($tableName, $pkName, $dbName=null)
 

Static Public Member Functions

static getAvailableDrivers ($dbWrapperClass=\Ubiquity\db\providers\pdo\PDOWrapper::class)
 
static start ($offset=null, $dbWrapperClass=\Ubiquity\db\providers\pdo\PDOWrapper::class)
 Starts and returns a database instance corresponding to an offset in config. More...
 
static getAvailableWrappers ()
 

Data Fields

 $quote
 

Static Public Attributes

static $wrappers = [ 'pdo' => \Ubiquity\db\providers\pdo\PDOWrapper::class
 

Protected Attributes

 $wrapperObject
 
- Protected Attributes inherited from DatabaseTransactionsTrait
 $transactionLevel = 0
 

Private Member Functions

 setDbWrapperClass ($dbWrapperClass, $dbType)
 

Private Attributes

static $dbType => '\Ubiquity\db\providers\tarantool\TarantoolWrapper','mysqli' => '\Ubiquity\db\providers\mysqli\MysqliWrapper','swoole' => '\Ubiquity\db\providers\swoole\SwooleWrapper' ]
 
 $serverName
 
 $port
 
 $dbName
 
 $user
 
 $password
 
 $cache
 
 $options
 

Additional Inherited Members

- Protected Member Functions inherited from DatabaseTransactionsTrait
 nestable ()
 

Detailed Description

Ubiquity Generic database class.

Ubiquity$Database This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.1.0

Definition at line 24 of file Database.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $dbWrapperClass,
  $dbType,
  $dbName,
  $serverName = "127.0.0.1",
  $port = "3306",
  $user = "root",
  $password = "",
  $options = [],
  $cache = false,
  $pool = null 
)

Constructor.

Parameters
string$dbWrapperClass
string$dbName
string$serverName
string$port
string$user
string$password
array$options
boolean | string$cache
mixed$pool

Definition at line 55 of file Database.php.

Member Function Documentation

◆ close()

close ( )

Closes the active connection.

Definition at line 222 of file Database.php.

◆ connect()

connect ( )

Creates the Db instance and realize a safe connection.

Exceptions
DBException
Returns
boolean

Definition at line 90 of file Database.php.

◆ freePool()

freePool (   $db)

For databases with Connection pool (put a dbInstance in pool wrapper)

Definition at line 254 of file Database.php.

◆ getAvailableDrivers()

static getAvailableDrivers (   $dbWrapperClass = \Ubiquity\db\providers\pdo\PDOWrapper::class)
static

Definition at line 148 of file Database.php.

◆ getAvailableWrappers()

static getAvailableWrappers ( )
static

Definition at line 262 of file Database.php.

◆ getDbName()

getDbName ( )
Returns
string

Definition at line 135 of file Database.php.

◆ getDbType()

getDbType ( )
Returns
mixed

Definition at line 157 of file Database.php.

◆ getDSN()

getDSN ( )

Definition at line 99 of file Database.php.

◆ getOptions()

getOptions ( )
Returns
array

Definition at line 175 of file Database.php.

◆ getPassword()

getPassword ( )
Returns
string

Definition at line 166 of file Database.php.

◆ getPort()

getPort ( )
Returns
string

Definition at line 126 of file Database.php.

◆ getServerName()

getServerName ( )
Returns
string

Definition at line 108 of file Database.php.

◆ getUser()

getUser ( )
Returns
string

Definition at line 144 of file Database.php.

◆ pool()

pool ( )

For databases with Connection pool (retrieve a new dbInstance from pool wrapper)

Definition at line 247 of file Database.php.

◆ setDbName()

setDbName (   $dbName)
Parameters
string$dbName

Definition at line 191 of file Database.php.

◆ setDbType()

setDbType (   $dbType)

Definition at line 116 of file Database.php.

◆ setDbWrapperClass()

setDbWrapperClass (   $dbWrapperClass,
  $dbType 
)
private

Definition at line 79 of file Database.php.

◆ setOptions()

setOptions (   $options)
Parameters
array$options

Definition at line 215 of file Database.php.

◆ setPassword()

setPassword (   $password)
Parameters
string$password

Definition at line 207 of file Database.php.

◆ setPool()

setPool (   $pool)

Definition at line 258 of file Database.php.

◆ setPort()

setPort (   $port)
Parameters
string$port

Definition at line 183 of file Database.php.

◆ setServerName()

setServerName (   $serverName)

Definition at line 112 of file Database.php.

◆ setUser()

setUser (   $user)
Parameters
string$user

Definition at line 199 of file Database.php.

◆ start()

static start (   $offset = null,
  $dbWrapperClass = \Ubiquity\db\providers\pdo\PDOWrapper::class 
)
static

Starts and returns a database instance corresponding to an offset in config.

Parameters
string$offset
string$dbWrapperClass
Returns
|NULL

Definition at line 233 of file Database.php.

Field Documentation

◆ $cache

$cache
private

Definition at line 32 of file Database.php.

◆ $dbName

$dbName
private

Definition at line 29 of file Database.php.

◆ $dbType

$dbType => '\Ubiquity\db\providers\tarantool\TarantoolWrapper','mysqli' => '\Ubiquity\db\providers\mysqli\MysqliWrapper','swoole' => '\Ubiquity\db\providers\swoole\SwooleWrapper' ]
private

Definition at line 25 of file Database.php.

◆ $options

$options
private

Definition at line 33 of file Database.php.

◆ $password

$password
private

Definition at line 31 of file Database.php.

◆ $port

$port
private

Definition at line 28 of file Database.php.

◆ $quote

$quote

Definition at line 34 of file Database.php.

◆ $serverName

$serverName
private

Definition at line 27 of file Database.php.

◆ $user

$user
private

Definition at line 30 of file Database.php.

◆ $wrapperObject

$wrapperObject
protected

Definition at line 40 of file Database.php.

◆ $wrappers

$wrappers = [ 'pdo' => \Ubiquity\db\providers\pdo\PDOWrapper::class
static

Definition at line 25 of file Database.php.


The documentation for this class was generated from the following file: