Combu Server  3.1.1
PHP API Documentation
Public Member Functions | Protected Member Functions | Protected Attributes
Database Class Reference
Inheritance diagram for Database:
DatabasePDO

Public Member Functions

 __construct ($dbType, $dbServer, $dbPort, $dbName, $dbUser, $dbPass)
 
 GetConnection ()
 
 CloseConnection ()
 
 TestConnection ()
 
 Query ($query)
 
 InsertedId ($name=NULL)
 
 AffectedRows ()
 
 FetchAssoc ($result)
 
 FetchNum ($result)
 
 Escape ($text)
 
 EscapeDate ($text)
 
 RecordExists ($query)
 
 TransactionStart ()
 
 TransactionCommit ()
 
 TransactionRollback ()
 
 GetError ()
 
 GetErrorNo ()
 

Protected Member Functions

 _setConnection ()
 
 _selectDatabase ()
 

Protected Attributes

 $_dbType
 
 $_dbServer
 
 $_dbPort
 
 $_dbName
 
 $_dbUser
 
 $_dbPass
 
 $_connection
 

Detailed Description

Class to handle database connection and query using mysqli

Author
Skared Creations

Definition at line 10 of file Database.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $dbType,
  $dbServer,
  $dbPort,
  $dbName,
  $dbUser,
  $dbPass 
)

Class constructor

Definition at line 31 of file Database.php.

Member Function Documentation

◆ _selectDatabase()

_selectDatabase ( )
protected

Selects the database specified for this instance

Definition at line 64 of file Database.php.

◆ _setConnection()

_setConnection ( )
protected

Open the connection to the database

Definition at line 52 of file Database.php.

◆ AffectedRows()

AffectedRows ( )

Returns the records count affected by last query

Returns
int The affected records count

Definition at line 117 of file Database.php.

◆ CloseConnection()

CloseConnection ( )

Closes the connection to the database

Definition at line 72 of file Database.php.

◆ Escape()

Escape (   $text)

Escape a string to be used in a query

Parameters
string$textThe string value to escape
Returns
string The escaped string

Definition at line 163 of file Database.php.

◆ EscapeDate()

EscapeDate (   $text)

Escape a date/datetime to be used in a query

Parameters
string$textThe date/datetime string value to escape
Returns
string The escaped date string

Definition at line 172 of file Database.php.

◆ FetchAssoc()

FetchAssoc (   $result)

Fetch next record from a resource as associative array

Parameters
MySQL_Result$resultResource
Returns
MySQL_Fetch Result from fetch

Definition at line 143 of file Database.php.

◆ FetchNum()

FetchNum (   $result)

Fetch next record from a resource as associative array

Parameters
MySQL_Result$resultResource
Returns
MySQL_Fetch Result from fetch

Definition at line 154 of file Database.php.

◆ GetConnection()

GetConnection ( )

Returns the connection resource

Returns
MySQL_Resource Oggetto connessione

Definition at line 45 of file Database.php.

◆ GetError()

GetError ( )

Returns the description of the last error occurred

Returns
string The error description

Definition at line 235 of file Database.php.

◆ GetErrorNo()

GetErrorNo ( )

Returns the code of the last error occurred

Returns
string The error code

Definition at line 243 of file Database.php.

◆ InsertedId()

InsertedId (   $name = NULL)

Returns the autoincrement field value of the last INSERT query

Returns
int

Definition at line 106 of file Database.php.

◆ Query()

Query (   $query)

Executes a query on the database

Parameters
string$querySQL query string to execute
Returns
MySQL_Result Query result

Definition at line 95 of file Database.php.

◆ RecordExists()

RecordExists (   $query)

Check if a record exists from a specified query

Parameters
string$querySELECT query to execute
Returns
boolean Returns TRUE if at least one record exists

Definition at line 187 of file Database.php.

◆ TestConnection()

TestConnection ( )

Tests the database connection

Returns
boolean Returns TRUE if connection is alive

Definition at line 83 of file Database.php.

◆ TransactionCommit()

TransactionCommit ( )

Commits a transaction

Returns
boolean Returns TRUE if the transaction was committed successfully

Definition at line 213 of file Database.php.

◆ TransactionRollback()

TransactionRollback ( )

Rollbacks a transaction

Returns
boolean Returns TRUE if the transaction was rolled back successfully

Definition at line 224 of file Database.php.

◆ TransactionStart()

TransactionStart ( )

Starts a transaction

Returns
boolean Returns TRUE if the transaction started successfully

Definition at line 202 of file Database.php.

Field Documentation

◆ $_connection

$_connection
protected

Definition at line 26 of file Database.php.

◆ $_dbName

$_dbName
protected

Definition at line 18 of file Database.php.

◆ $_dbPass

$_dbPass
protected

Definition at line 20 of file Database.php.

◆ $_dbPort

$_dbPort
protected

Definition at line 17 of file Database.php.

◆ $_dbServer

$_dbServer
protected

Definition at line 16 of file Database.php.

◆ $_dbType

$_dbType
protected

Instance connection settings

Definition at line 15 of file Database.php.

◆ $_dbUser

$_dbUser
protected

Definition at line 19 of file Database.php.