SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SlaxWeb\DatabasePDO\Library Class Reference
Inheritance diagram for SlaxWeb\DatabasePDO\Library:
Inheritance graph
[legend]
Collaboration diagram for SlaxWeb\DatabasePDO\Library:
Collaboration graph
[legend]

Public Member Functions

 __construct (Closure $pdoLoader)
 
 execute (string $query, array $data=[])
 
 fetch ()
 
 lastError ()
 

Protected Member Functions

 setError (string $query="", array $errInfo=[])
 
 getPdo ()
 

Protected Attributes

 $delim = "\""
 
 $pdo = null
 
 $pdoLoader = null
 
 $stmnt = null
 
 $error = null
 

Additional Inherited Members

- Public Attributes inherited from SlaxWeb\Database\Interfaces\Library
const DB_CUBRID = "cubrid"
 
const DB_DBLIB = "dblib"
 
const DB_FIREBIRD = "firebird"
 
const DB_IBM = "ibm"
 
const DB_INFORMIX = "informix"
 
const DB_MYSQL = "mysql"
 
const DB_OCI = "oci"
 
const DB_ODBC = "odbc"
 
const DB_PGSQL = "pgsql"
 
const DB_SQLITE = "sqlite"
 
const DB_SQLSRV = "sqlsrv"
 
const DB_4D = "4d"
 

Constructor & Destructor Documentation

SlaxWeb\DatabasePDO\Library::__construct ( Closure  $pdoLoader)

Class constrcutor

Initiates the class and assigns the dependencies to local properties for later use.

Parameters
\Closure$pdoLoaderPDO lazy load Closure

Member Function Documentation

SlaxWeb\DatabasePDO\Library::execute ( string  $query,
array  $data = [] 
)

Execute Query

Executes the received query and binds the received parameters into the query to decrease the chance of an SQL injection. Returns bool(true) if query was successfuly executed, and bool(false) if it was not. If the query yielded a result set, a Result object will be populated.

Parameters
string$queryThe Query to be executed
array$dataData to be bound into the Query, default []
Returns
bool

Implements SlaxWeb\Database\Interfaces\Library.

SlaxWeb\DatabasePDO\Library::fetch ( )

Fetch Results

It fetches the results from the last executed statement, creates the Result object and returns it. If an statement has not yet been executed or did not yield a valid result set, an exception is thrown.

Returns

Implements SlaxWeb\Database\Interfaces\Library.

SlaxWeb\DatabasePDO\Library::getPdo ( )
protected

Get PDO

Gets the PDO from the closure or from the internal property.

Returns
SlaxWeb\DatabasePDO\Library::lastError ( )

Get last error

Retrieves the error of the last executed query. If there was no error, an exception must be thrown.

Returns

Implements SlaxWeb\Database\Interfaces\Library.

SlaxWeb\DatabasePDO\Library::setError ( string  $query = "",
array  $errInfo = [] 
)
protected

Set error

Sets the error based on PDOs error info.

Parameters
string$queryQuery that caused the error. Default ""
array$errInfoError info array, if left empty PDO Error Info array is obtained
Returns
void

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