Relational Database Interface
The DB Adapter module provides classes for access to relational database via PDO (PHP Data Object) drivers and classes. This approach allows developers to use these classes to access a range of different database servers.
PDO has supporting drivers for:
Access to database functions is all implemented using a common class structure. This allows developers to create database queries in code without consideration for the underlying SQL. SQL is generated "under the hood" using a database specific driver that will automatically take care of any differences in the database servers SQL implementation.
$db = Hazaar\DBI\Adapter::getInstance();
$result = $this->execute('SELECT * FROM users');
while($row = $result->fetch()){
//Do things with $row here
}
public array $defaultConfig
public BaseDriver $driver
private array $loadedConfigs
public Manager $schemaManager
private array $connections
private array $managerInstances
private array $statements
Hazaar DBI Constructor.
public __construct({Array})
Parameter | Type | Description |
---|
$config | string | An array of configuration options to instantiate the DBI Adapter. This can |
also be a Hazaar MVC configuration environment if DBI is being used by an HMVC
application. |
Parameter | Type | Description |
---|
$method | string | |
$args | array | |
public getInstance({Array})
Parameter | Type | Description |
---|
$configEnv | string | |
public getSchemaManagerInstance({Array})
Parameter | Type | Description |
---|
$configEnv | string | |
$logCallback | callable | |
public getDriverClass({Array})
Parameter | Type | Description |
---|
$driver | string | |
public setDefaultConfig({Array})
Parameter | Type | Description |
---|
$config | string | |
$env | string | |
public getDefaultConfig({Array})
Parameter | Type | Description |
---|
$configName | string | |
Parameter | Type | Description |
---|
$dsn | string | |
$username | string | |
$password | string | |
$driverOptions | array | |
$reconnect | bool | |
public getDriver({Array})
public getAvailableDrivers({Array})
Build a sub-query using an existing query.
Parameter | Type | Description |
---|
$subquery | Table | Table The existing query to use as the sub-query |
$name | string | The named alias of the sub-query |
Parameter | Type | Description |
---|
$sql | string | |
Parameter | Type | Description |
---|
$table | string | |
$criteria | mixed | |
Parameter | Type | Description |
---|
$name | string | |
$alias | string | |
Parameter | Type | Description |
---|
$name | string | |
$alias | string | |
Parameter | Type | Description |
---|
$method | string | |
$args | array | |
$criteria | mixed | |
Prepared statements.
Parameter | Type | Description |
---|
$sql | string | |
$name | string | |
Parameter | Type | Description |
---|
$name | string | |
$inputParameters | array | |
public getPreparedStatements({Array})
public listPreparedStatements({Array})
Returns an instance of the Hazaar\DBI\Schema\Manager for managing database schema versions.
public getSchemaManager({Array})
Perform and "upsert".
An upsert is an INSERT, that when it fails, columns can be updated in the existing row.
Parameter | Type | Description |
---|
$tableName | string | the table to insert a record into |
$fields | mixed | the fields to be inserted |
$returning | mixed | a column to return when the row is inserted (usually the primary key) |
$conflictTarget | string | the column(s) to check for a conflict. If the conflict is found, |
the row will be updated. |
| $conflictUpdate
| array
| | | $table
| Table
| | | $
| int
| |
Parameter | Type | Description |
---|
$tableName | string | |
$fields | mixed | |
$criteria | mixed | |
$from | array | |
$returning | mixed | |
$tables | array | |
$ | int | |
Parameter | Type | Description |
---|
$table | string | |
$data | mixed | |
public errorException({Array})
Parameter | Type | Description |
---|
$msg | string | |
Parse an SQL query into a DBI Table query so that it can be manipulated.
Parameter | Type | Description |
---|
$sql | string | The SQL query to parse |
Grant privileges on a table to a user.
Parameter | Type | Description |
---|
$table | string | the name of the table to grant privileges on |
$user | string | The name of the user who is being given the privileges |
$privileges | string | One or more privileges being applied. Example: (string)'ALL' and (array)['INSERT', 'UPDATE', 'DELETE'] are both valid. |
private reconfigure({Array})
Parameter | Type | Description |
---|
$reconnect | bool | |
Generated by Hazaar API Doc Generator