Property | Type | Description | |
---|---|---|---|
$LOG_ERRORS | boolean | Write all errors to error log | |
$TIMESTAMP_WRITES | boolean | Automatically add/update created/updated fields |
Property | Type | Description | |
---|---|---|---|
$config_master | Dynamic master config creds | ||
$config_slaves | Dynamic slave config creds | ||
$instance | PDOWrapper | A reference to the singleton instance | |
$pdo_exception | We will cache any PDO errors in case we want to get out them externally | ||
$pdo_master | The PDO objects for the master connection | ||
$pdo_slave | The PDO objects for the slave connection |
Method | Description | |
---|---|---|
__destruct ( ) | Destructor. | |
configMaster ( $host, $name, $user, $password, $port = null, $driver = 'mysql' ) | method configMaster - configure connection credentials to the master db server | |
configSlave ( $host, $name, $user, $password, $port = null, $driver = 'mysql' ) | method configSlave - configure a connection to a slave (can be called multiple times) | |
delete ( $table, $params = [] ) : boolean | method delete. | |
execute ( string $query, $params = [] ) : mixed | method execute. | |
getErrorMessage ( ) | method getErrorMessage. | |
getPDOException ( ) | method getError. | |
insert ( string $table, array $params = [], boolean $timestamp_this = null ) : mixed | method insert. | |
insertMultiple ( string $table, array $columns = [], $rows = [], boolean $timestamp_these = null ) : mixed | method insertMultiple. | |
instance ( ) : - | method instance. | |
query ( string $query, array $params = [], boolean $use_master = false ) : mixed | method query. | |
queryFirst ( string $query, array $params = [], boolean $use_master = false ) : mixed | method queryFirst. | |
select ( string $table, array $params = null, integer $limit = null, integer $start = null, array $order_by = null, boolean $use_master = false ) : mixed | method select. | |
selectFirst ( $table, $params = [], array $order_by = null ) : mixed | method selectFirst. | |
selectFirstMaster ( $table, $params = [], array $order_by = null ) : mixed | method selectFirstMaster. | |
selectMaster ( $table, $params = [], integer $limit = null, integer $start = null, array $order_by = null ) : mixed | method selectMaster. | |
update ( string $table, array $params, array $wheres = [], boolean $timestamp_this = null ) : integer | boolean | method update. |
Method | Description | |
---|---|---|
__construct ( ) | Constructor. | |
createConnection ( $driver, $host, $name, $user, $password, $port = null ) : PDO | method createConnection. | |
getMaster ( ) | method getMaster. | |
getSlave ( ) | method getSlave. |
Method | Description | |
---|---|---|
validateDriver ( string $driver ) : boolean | Validate the database in question is supported by your installation of PHP. |
protected __construct ( ) |
public configMaster ( $host, $name, $user, $password, $port = null, $driver = 'mysql' ) |
public configSlave ( $host, $name, $user, $password, $port = null, $driver = 'mysql' ) |
protected createConnection ( $driver, $host, $name, $user, $password, $port = null ) : PDO | ||
return | PDO | object with a connection to the database specified |
protected getSlave ( ) |
public insert ( string $table, array $params = [], boolean $timestamp_this = null ) : mixed | ||
$table | string | - the name of the db table we are adding row to |
$params | array | - associative array representing the columns and their respective values |
$timestamp_this | boolean | (Optional), if true we set date_created and date_modified values to now |
return | mixed | - new primary key of inserted table, false on failure |
public insertMultiple ( string $table, array $columns = [], $rows = [], boolean $timestamp_these = null ) : mixed | ||
$table | string | - the name of the db table we are adding row to |
$columns | array | - contains the column names |
$timestamp_these | boolean | (Optional), if true we set date_created and date_modified values to NOW() for each row |
return | mixed | - new primary key of inserted table, false on failure |
public static instance ( ) : - | ||
return | - |
public query ( string $query, array $params = [], boolean $use_master = false ) : mixed | ||
$query | string | - the SQL query we are executing |
$params | array | - a list of bind parameters |
$use_master | boolean | (Optional) - whether or not to use the master connection |
return | mixed | - the affected rows, false on failure |
public queryFirst ( string $query, array $params = [], boolean $use_master = false ) : mixed | ||
$query | string | - the SQL query we are executing |
$params | array | - a list of bind parameters |
$use_master | boolean | (Optional) - whether or not to use the master connection |
return | mixed | - the affected rows, false on failure |
public select ( string $table, array $params = null, integer $limit = null, integer $start = null, array $order_by = null, boolean $use_master = false ) : mixed | ||
$table | string | - the name of the db table we are retreiving the rows from |
$params | array | - associative array representing the WHERE clause filters |
$limit | integer | (optional) - the amount of rows to return |
$start | integer | (optional) - the row to start on, indexed by zero |
$order_by | array | (optional) - an array with order by clause |
$use_master | boolean | (optional) - use the master db for this read |
return | mixed | - associate representing the fetched table row, false on failure |
public selectFirst ( $table, $params = [], array $order_by = null ) : mixed | ||
$order_by | array | (optional) - an array with order by clause |
return | mixed | - associate representing the fetched table row, false on failure |
public selectFirstMaster ( $table, $params = [], array $order_by = null ) : mixed | ||
$order_by | array | (optional) - an array with order by clause |
return | mixed | - associate representing the fetched table row, false on failure |
public selectMaster ( $table, $params = [], integer $limit = null, integer $start = null, array $order_by = null ) : mixed | ||
$limit | integer | (optional) - the amount of rows to return |
$start | integer | (optional) - the row to start on, indexed by zero |
$order_by | array | (optional) - an array with order by clause |
return | mixed | - associate representing the fetched table row, false on failure |
public update ( string $table, array $params, array $wheres = [], boolean $timestamp_this = null ) : integer | boolean | ||
$table | string | - the name of the db table we are adding row to |
$params | array | - associative array representing the columns and their respective values to update |
$wheres | array | (Optional) - the where clause of the query |
$timestamp_this | boolean | (Optional) - if true we set date_created and date_modified values to now |
return | integer | boolean | - the amount of rows updated, false on failure |
public static bool $LOG_ERRORS | ||
return | boolean |
public static bool $TIMESTAMP_WRITES | ||
return | boolean |
protected static PDOWrapper $instance | ||
return | PDOWrapper |
protected $pdo_exception |