Properties

$options

$options : array

Type

array — used when creating the PDO object

$pdo

$pdo : 

Type

$stmt

$stmt : 

Type

$numQueries

$numQueries : integer

Type

integer — count all queries made

$queries

$queries : 

Type

$params

$params : 

Type

Methods

__construct()

__construct(array  $options = array()) 

Constructor creating a PDO object connecting to a choosen database.

Parameters

array $options

containing details for connecting to the database.

setOptions()

setOptions(array  $options = array()) : void

Set options and connection details.

Parameters

array $options

containing details for connecting to the database.

setOption()

setOption(string  $option, mixed  $value) : self

Set a single option.

Parameters

string $option

which to set.

mixed $value

to set.

Returns

self

connect()

connect() : self

Connect to the database.

Returns

self

executeFetchAll()

executeFetchAll(string  $query, array  $params = array()) : mixed

Execute a select-query with arguments and return the resultset.

Parameters

string $query

the SQL statement

array $params

the params array

Returns

mixed —

with resultset

executeFetch()

executeFetch(string  $query, array  $params = array()) : mixed

Execute a select-query with arguments and return the first row in the resultset.

Parameters

string $query

the SQL statement

array $params

the params array

Returns

mixed —

with resultset

executeFetchClass()

executeFetchClass(string  $query, array  $params, string  $class) : object

Execute a select-query with arguments and insert the results into a new object of the class.

Parameters

string $query

the SQL statement

array $params

the params array

string $class

the class to create an object of and insert into

Returns

object —

with resultset

executeFetchInto()

executeFetchInto(string  $query, array  $params, string  $object = null) : object

Execute a select-query with arguments and insert the results into an existing object.

Parameters

string $query

the SQL statement

array $params

the params array

string $object

the existing object to insert into

Returns

object —

with resultset

fetchAll()

fetchAll() : array

Fetch all resultset.

Returns

array —

with resultset.

fetch()

fetch() : mixed

Fetch one resultset.

Returns

mixed —

with resultset.

fetchClass()

fetchClass(string  $classname) : object

Fetch one resultset as a new object from this class.

Parameters

string $classname

which type of object to instantiate.

Returns

object —

with resultset.

fetchAllClass()

fetchAllClass(string  $classname) : array

Fetch full resultset as new objects from this class.

Parameters

string $classname

which type of object to instantiate.

Returns

array —

with resultset.

fetchInto()

fetchInto(object  $object) : array

Fetch one resultset into an object.

Parameters

object $object

to insert values into.

Returns

array —

with resultset.

execute()

execute(string  $query, array  $params = array()) : boolean

Execute a SQL-query and ignore the resultset.

Parameters

string $query

the SQL statement

array $params

the params array

Throws

\Anax\Database\Exception

when failing to prepare question.

Returns

boolean —

returns TRUE on success or FALSE on failure.

lastInsertId()

lastInsertId() : integer

Return last insert id from autoincremented key on INSERT.

Returns

integer —

as last insert id.

rowCount()

rowCount() : integer

Return rows affected of last INSERT, UPDATE, DELETE

Returns

integer —

as rows affected on last statement

fetchObject()

fetchObject(string  $classname) : object

Fetch one resultset as an object from this class.

OBSOLETE replaced by fetchClass

Parameters

string $classname

which type of object to instantiate.

Returns

object —

with resultset.

fetchOne()

fetchOne() : mixed

Fetch one resultset. OBSOLETE replace by fetch()

Returns

mixed —

with resultset.

loadHistory()

loadHistory() : integer

Load query-history from session if available.

Returns

integer —

number of database queries made.

saveHistory()

saveHistory(string  $extra = null) : void

Save query-history in session, useful as a flashmemory when redirecting to another page.

Parameters

string $extra

enables to save some extra debug information.

getNumQueries()

getNumQueries() : integer

Get how many queries have been processed.

Returns

integer —

number of database queries made.

getQueries()

getQueries() : array

Get all the queries that have been processed.

Returns

array —

with queries.

dump()

dump() : string

Get a HTML representation of all queries made, for debugging and analysing purpose.

Returns

string —

with HTML.

createException()

createException(string  $msg, string  $query, array  $param) : void

Throw exception using detailed message.

Parameters

string $msg

detailed error message from PDO

string $query

query to execute

array $param

to match ? in statement

Throws

\Anax\Database\Exception

pdoException()

pdoException(string  $query, array  $param) : void

Throw exception when pdo failed using detailed message.

Parameters

string $query

query to execute

array $param

to match ? in statement

Throws

\Anax\Database\Exception

statementException()

statementException(string  $query, array  $param) : void

Throw exception when statement failed using detailed message.

Parameters

string $query

query to execute

array $param

to match ? in statement

Throws

\Anax\Database\Exception

expandParamArray()

expandParamArray(string  $query, array  $params) : array

Support arrays in params, extract array items and add to $params and insert ? for each entry in the array.

Parameters

string $query

as the query to prepare.

array $params

the parameters that may contain arrays.

Returns

array —

with query and params.