Ubiquity  2.3.0
php rapid development framework
Database Class Reference

Ubiquity PDO database class. More...

+ Inheritance diagram for Database:

Public Member Functions

 __construct ($dbType, $dbName, $serverName="127.0.0.1", $port="3306", $user="root", $password="", $options=[], $cache=false)
 Constructor. More...
 
 connect ()
 Creates the PDO 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 pdo connection. More...
 
- Public Member Functions inherited from DatabaseOperationsTrait
 getDSN ()
 
 getPdoObject ()
 
 _connect ()
 
 query ($sql)
 Executes an SQL statement, returning a result set as a PDOStatement 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)
 
 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 (\PDOStatement $statement, $parameter, $value)
 Sets $value to $parameter. More...
 
 lastInserId ()
 Returns the last insert id. More...
 
 getTablesName ()
 
 count ($tableName, $condition='')
 Returns the number of records in $tableName that respects 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...
 

Static Public Member Functions

static getAvailableDrivers ()
 
static start ($offset=null)
 Starts and returns a database instance corresponding to an offset in config. More...
 

Protected Attributes

 $pdoObject
 
- Protected Attributes inherited from DatabaseTransactionsTrait
static $transactionLevel = 0
 

Private Attributes

 $dbType
 
 $serverName
 
 $port
 
 $dbName
 
 $user
 
 $password
 
 $cache
 
 $options
 

Additional Inherited Members

- Protected Member Functions inherited from DatabaseTransactionsTrait
 nestable ()
 
- Static Protected Attributes inherited from DatabaseTransactionsTrait
static $savepointsDrivers = [ 'pgsql' => true
 

Detailed Description

Ubiquity PDO 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.0.5

Definition at line 23 of file Database.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

Definition at line 50 of file Database.php.

Member Function Documentation

◆ close()

close ( )

Closes the active pdo connection.

Definition at line 211 of file Database.php.

◆ connect()

connect ( )

Creates the PDO instance and realize a safe connection.

Exceptions
DBException
Returns
boolean

Definition at line 79 of file Database.php.

◆ getAvailableDrivers()

static getAvailableDrivers ( )
static

Definition at line 137 of file Database.php.

◆ getDbName()

getDbName ( )
Returns
string

Definition at line 124 of file Database.php.

◆ getDbType()

getDbType ( )
Returns
mixed

Definition at line 146 of file Database.php.

◆ getDSN()

getDSN ( )

Definition at line 88 of file Database.php.

◆ getOptions()

getOptions ( )
Returns
array

Definition at line 164 of file Database.php.

◆ getPassword()

getPassword ( )
Returns
string

Definition at line 155 of file Database.php.

◆ getPort()

getPort ( )
Returns
string

Definition at line 115 of file Database.php.

◆ getServerName()

getServerName ( )
Returns
string

Definition at line 97 of file Database.php.

◆ getUser()

getUser ( )
Returns
string

Definition at line 133 of file Database.php.

◆ setDbName()

setDbName (   $dbName)
Parameters
string$dbName

Definition at line 180 of file Database.php.

◆ setDbType()

setDbType (   $dbType)

Definition at line 105 of file Database.php.

◆ setOptions()

setOptions (   $options)
Parameters
array$options

Definition at line 204 of file Database.php.

◆ setPassword()

setPassword (   $password)
Parameters
string$password

Definition at line 196 of file Database.php.

◆ setPort()

setPort (   $port)
Parameters
string$port

Definition at line 172 of file Database.php.

◆ setServerName()

setServerName (   $serverName)

Definition at line 101 of file Database.php.

◆ setUser()

setUser (   $user)
Parameters
string$user

Definition at line 188 of file Database.php.

◆ start()

static start (   $offset = null)
static

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

Parameters
string$offset
Returns
|NULL

Definition at line 221 of file Database.php.

Field Documentation

◆ $cache

$cache
private

Definition at line 30 of file Database.php.

◆ $dbName

$dbName
private

Definition at line 27 of file Database.php.

◆ $dbType

$dbType
private

Definition at line 24 of file Database.php.

◆ $options

$options
private

Definition at line 31 of file Database.php.

◆ $password

$password
private

Definition at line 29 of file Database.php.

◆ $pdoObject

$pdoObject
protected

Definition at line 37 of file Database.php.

◆ $port

$port
private

Definition at line 26 of file Database.php.

◆ $serverName

$serverName
private

Definition at line 25 of file Database.php.

◆ $user

$user
private

Definition at line 28 of file Database.php.


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