Methods

__construct()

__construct(string  $dsn, string  $username = NULL, string  $password = NULL, array  $driverOptions = array()) 

Constructor/Connection method

Parameters

string $dsn
string $username
string $password
array $driverOptions

beginTransaction()

beginTransaction() : boolean

Initiates a transaction

Throws

\PDOException

Returns

boolean

commit()

commit() : boolean

Commits a transaction

Throws

\PDOException

Returns

boolean

errorCode()

errorCode() : mixed

Fetch the SQLSTATE associated with the last operation on the database handle

Returns

mixed

errorInfo()

errorInfo() : array

Fetch extended error information associated with the last operation on the database handle

Returns

array

exec()

exec(string  $statement) : integer

Execute an SQL statement and return the number of affected rows

Parameters

string $statement

Returns

integer

getAttribute()

getAttribute(integer  $attribute) : mixed

Retrieve a database connection attribute

Parameters

integer $attribute

Returns

mixed

getAvailableDrivers()

getAvailableDrivers() : array

Return an array of available PDO drivers

Returns

array

inTransaction()

inTransaction() : boolean

Checks if inside a transaction

Returns

boolean

lastInsertId()

lastInsertId(string  $name = NULL) : string

Returns teh ID of the last inserted row or sequence value

Parameters

string $name

Name of the sequence object from which the ID should be returned

Returns

string

prepare()

prepare(string  $statement, array  $options = NULL) : \PDOStatement

Prepares a statement for execution and returns a statement object

Parameters

string $statement
array $options

Returns

\PDOStatement

query()

query() : \PDOStatement

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

Returns

\PDOStatement

quote()

quote(string  $string, integer  $parameterType = \PDO::PARAM_STR) : string|false

Quotes a string for use in a query

Parameters

string $string
integer $parameterType

Returns

string|false

rollBack()

rollBack() : boolean

Rolls back a transaction

Throws

\PDOException

Returns

boolean

setAttribute()

setAttribute(integer  $attribute, mixed  $value) : boolean

Set an attribute

Parameters

integer $attribute
mixed $value

Returns

boolean

prepareQuery()

prepareQuery(string  $sql, array  $data) : \PDOStatement

Simplifies prepared statements for database queries

Parameters

string $sql
array $data

Throws

\InvalidArgumentException

Returns

\PDOStatement —

| FALSE

getColumns()

getColumns(string  $table) : array

Retrieve column information for the current database table

Parameters

string $table

Returns

array

getTypes()

getTypes() : array

Retrieve list of data types for the database

Returns

array

getIndexes()

getIndexes(string  $table) : array

Retrieve indexes for the table

Parameters

string $table

Returns

array

getFks()

getFks(string  $table) : array

Retrieve foreign keys for the table

Parameters

string $table

Returns

array

getTables()

getTables() : array

Return list of tables for the current database

Returns

array

getSystemTables()

getSystemTables() : array

Retrieves an array of non-user-created tables for the connection/database

Returns

array

getDbs()

getDbs() : array

Return list of dbs for the current connection, if possible

Returns

array

getViews()

getViews() : array

Return list of views for the current database

Returns

array

getSequences()

getSequences() : array

Return list of sequences for the current database, if they exist

Returns

array

getFunctions()

getFunctions() : array

Return list of functions for the current database

Returns

array

getProcedures()

getProcedures() : array

Return list of stored procedures for the current database

Returns

array

getTriggers()

getTriggers() : array

Return list of triggers for the current database

Returns

array

quoteIdent()

quoteIdent(string|array  $ident) : string|array

Surrounds the string with the databases identifier escape characters

Parameters

string|array $ident

Returns

string|array

quoteTable()

quoteTable(string|array  $table) : string|array

Quote database table name, and set prefix

Parameters

string|array $table

Returns

string|array

prepareExecute()

prepareExecute(string  $sql, array  $params) : \PDOStatement

Create and execute a prepared statement with the provided parameters

Parameters

string $sql
array $params

Returns

\PDOStatement

driverQuery()

driverQuery(string|array|null  $query, boolean  $filteredIndex = TRUE) : array

Method to simplify retrieving db results for meta-data queries

Parameters

string|array|null $query
boolean $filteredIndex

Returns

array

affectedRows()

affectedRows() : integer

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

Returns

integer

numRows()

numRows() : integer

Return the number of rows returned for a SELECT query

Returns

integer

prefixTable()

prefixTable(string  $table) : string

Prefixes a table if it is not already prefixed

Parameters

string $table

Returns

string

insertBatch()

insertBatch(string  $table, array  $data = array()) : array

Create sql for batch insert

Parameters

string $table
array $data

Returns

array

updateBatch()

updateBatch(string  $table, array|object  $data, string  $where) : integer|null

Creates a batch update, and executes it.

Returns the number of affected rows

Parameters

string $table
array|object $data
string $where

Returns

integer|null

setLastQuery()

setLastQuery(string  $queryString) : void

Set the last query sql

Parameters

string $queryString