Ubiquity  2.0.2
php rapid development framework
Database Class Reference

Public Member Functions

 __construct ($dbType, $dbName, $serverName="localhost", $port="3306", $user="root", $password="", $options=[], $cache=false)
 Constructor. More...
 
 connect ()
 Creates the PDO instance. More...
 
 query ($sql)
 Executes an SQL statement, returning a result set as a PDOStatement object. More...
 
 prepareAndExecute ($tableName, $condition, $fields, $useCache=NULL)
 
 execute ($sql)
 Execute an SQL statement and return the number of affected rows (INSERT, UPDATE or DELETE) More...
 
 getServerName ()
 
 setServerName ($serverName)
 
 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...
 
 isConnected ()
 
 setDbType ($dbType)
 
 getPort ()
 
 getDbName ()
 
 getUser ()
 
 getPdoObject ()
 

Private Member Functions

 getStatement ($sql)
 

Private Attributes

 $dbType
 
 $serverName
 
 $port
 
 $dbName
 
 $user
 
 $password
 
 $pdoObject
 
 $statements =[ ]
 
 $cache
 
 $options
 

Detailed Description

Definition at line 15 of file Database.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $dbType,
  $dbName,
  $serverName = "localhost",
  $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 37 of file Database.php.

Member Function Documentation

◆ bindValueFromStatement()

bindValueFromStatement ( \PDOStatement  $statement,
  $parameter,
  $value 
)

Sets $value to $parameter.

Parameters
\PDOStatement$statement
String$parameter
mixed$value
Returns
boolean

Definition at line 148 of file Database.php.

◆ connect()

connect ( )

Creates the PDO instance.

Definition at line 63 of file Database.php.

◆ count()

count (   $tableName,
  $condition = '' 
)

Returns the number of records in $tableName that respects the condition passed as a parameter.

Parameters
string$tableName
string$conditionPartie suivant le WHERE d'une instruction SQL

Definition at line 171 of file Database.php.

◆ execute()

execute (   $sql)

Execute an SQL statement and return the number of affected rows (INSERT, UPDATE or DELETE)

Parameters
string$sql
Returns
int the number of rows that were modified or deleted by the SQL statement you issued

Definition at line 120 of file Database.php.

◆ getDbName()

getDbName ( )

Definition at line 190 of file Database.php.

◆ getPdoObject()

getPdoObject ( )

Definition at line 198 of file Database.php.

◆ getPort()

getPort ( )

Definition at line 186 of file Database.php.

◆ getServerName()

getServerName ( )

Definition at line 124 of file Database.php.

◆ getStatement()

getStatement (   $sql)
private
Parameters
string$sql
Returns

Definition at line 107 of file Database.php.

◆ getTablesName()

getTablesName ( )

Definition at line 160 of file Database.php.

◆ getUser()

getUser ( )

Definition at line 194 of file Database.php.

◆ isConnected()

isConnected ( )

Definition at line 177 of file Database.php.

◆ lastInserId()

lastInserId ( )

Returns the last insert id.

Returns
integer

Definition at line 156 of file Database.php.

◆ prepareAndExecute()

prepareAndExecute (   $tableName,
  $condition,
  $fields,
  $useCache = NULL 
)
Parameters
string$tableName
string$condition
array | string$fields
boolean | null$useCache
Returns
boolean|array

Definition at line 84 of file Database.php.

◆ prepareStatement()

prepareStatement (   $sql)

Prepares a statement for execution and returns a statement object.

Parameters
String$sql
Returns

Definition at line 137 of file Database.php.

◆ query()

query (   $sql)

Executes an SQL statement, returning a result set as a PDOStatement object.

Parameters
string$sql
Returns

Definition at line 73 of file Database.php.

◆ setDbType()

setDbType (   $dbType)

Definition at line 181 of file Database.php.

◆ setServerName()

setServerName (   $serverName)

Definition at line 128 of file Database.php.

Field Documentation

◆ $cache

$cache
private

Definition at line 24 of file Database.php.

◆ $dbName

$dbName
private

Definition at line 19 of file Database.php.

◆ $dbType

$dbType
private

Definition at line 16 of file Database.php.

◆ $options

$options
private

Definition at line 25 of file Database.php.

◆ $password

$password
private

Definition at line 21 of file Database.php.

◆ $pdoObject

$pdoObject
private

Definition at line 22 of file Database.php.

◆ $port

$port
private

Definition at line 18 of file Database.php.

◆ $serverName

$serverName
private

Definition at line 17 of file Database.php.

◆ $statements

$statements =[ ]
private

Definition at line 23 of file Database.php.

◆ $user

$user
private

Definition at line 20 of file Database.php.


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