$insert
$insert : array
Class Db
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.
| string | $sql | MySQL statement to be executed. |
| string | $fetchStyle | Can be any PDO::FETCH_x style. |
Returns affected rows in associative array.
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.
| string | $sql | MySQL statement to be executed. |
| array | $values | Associative array of values to be prepared. |
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.
| 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. |
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.
| $typeOfStatement | ||
| $userSuppliedData |
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.
| $insertTable |
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.
| $updateWhichTable | ||
| $updateByWhatColumn | ||
| $updateWhatId |
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.