Properties

$insert

$insert : array

Type

array

$values

$values : array

Type

array

$connection

$connection : null

Type

null

$iniPath

$iniPath : string

Set iniPath before using this class

Type

string — System path to the config.ini.

Methods

execPDOQuery()

execPDOQuery(string  $sql) : void

Execute MySql statement with no return.

-Experimental method-

Parameters

string $sql

MySQL query to be executed

singleReturnQuery()

singleReturnQuery(string  $sql, string  $fetchStyle) : mixed

Execute mySql query and return single record set

-Experimental method-

Parameters

string $sql

MySql query to be executed

string $fetchStyle

PDO fetch style to be used. I.e. PDO::FETCH_ASSOC

Returns

mixed

selectQuery()

selectQuery(string  $sql, string  $fetchStyle) : array

Execute a MySql query and return all affected rows.

This method uses PDO::FETCH_ALL, if the query is only returning one row, it may be better to use singleReturnQuery.

Parameters

string $sql

MySQL statement to be executed.

string $fetchStyle

Can be any PDO::FETCH_x style.

Returns

array —

Returns affected rows in associative array.

insert()

insert(string  $sql, array  $values) : void

Insert one or more rows into a MySQL Database

Accepts a query string and an array formatted like :key => value. Array key must have : to be bound to value correctly. Use the createSqlArray function for this.

Parameters

string $sql

MySQL statement to be executed.

array $values

Associative array of values to be prepared.

fetch()

fetch(string  $sql, array  $values, string  $fetchStyle) : mixed

Functions the same as insert, however will return a query array after supplying any PDO::FETCH_style.

Parameters

string $sql

MySQL statement to be executed.

array $values

Associative array of values to be prepared.

string $fetchStyle

Can be any PDO::FETCH_x style.

Returns

mixed

createSqlArray()

createSqlArray(  $typeOfStatement,   $userSuppliedData) : void

Creates two arrays to be used in conjunction with the insert and fetch functions.

Accepts two arguments. $typeOfStatement is used to determine if the function is returning a 'insert' array or an 'update' array. The second argument is an the userSuppliedData array which is used to populate the insert and values array.

Parameters

$typeOfStatement
$userSuppliedData

createSqlInsertStatement()

createSqlInsertStatement(  $insertTable) : string

Creates a mySql INSERT query for use with the insert function.

As this function is dependant on the insert & value arrays, createSqlArray must be executed prior to calling createSqlInsertStatement. Or the insert & value arrays must be populated by some other manner.

Parameters

$insertTable

Returns

string

makeSqlUpdateStatements()

makeSqlUpdateStatements(  $updateWhichTable,   $updateByWhatColumn,   $updateWhatId) : string

Creates a mySql UPDATE query for use with the insert function.

As this function is dependant on the insert & value arrays, createSqlArray must be executed prior to calling createSqlUpdateStatement. Or the insert & value arrays must be populated by some other manner.

Parameters

$updateWhichTable
$updateByWhatColumn
$updateWhatId

Returns

string

connect()

connect() : null|\PDO

Set up PDO instance

The connection instance is built using the parameters in the config.ini file. The connection instance is then returned to the calling method. Upon connection failure, PDO Exception is thrown along with error code. See http://php.net/manual/en/pdo.error-handling.php for more information.

Returns

null|\PDO