Base Database class

Extends PDO to simplify cross-database issues
package Query
subpackage Drivers

 Methods

PDO constructor wrapper

__construct(string $dsn, string $username = NULL, string $password = NULL, array $driver_options = array()

Parameters

$dsn

string

$username

string

$password

string

$driver_options

array

Helper method for quote_ident

_quote(mixed $str) : mixed

Parameters

$str

mixed

Returns

mixed

Returns number of rows affected by an INSERT, UPDATE, DELETE type query

affected_rows() : int

Returns

int

Method to simplify retreiving db results for meta-data queries

driver_query(string|array|null $query, bool $filtered_index = TRUE) : array

Parameters

$query

stringarraynull

$filtered_index

bool

Returns

array

Retrieve column information for the current database table

get_columns(string $table) : array

Parameters

$table

string

Returns

array

Return list of dbs for the current connection, if possible

get_dbs() : array

Returns

array

Return list of function for the current database

get_functions() : array

Returns

array

Return list of stored procedures for the current database

get_procedures() : array

Returns

array

Return schemas for databases that list them

get_schemas() : array

Returns

array

Return list of sequences for the current database, if they exist

get_sequences() : array

Returns

array

Retreives an array of non-user-created tables for the connection/database

get_system_tables() : array

Returns

array

Return list of tables for the current database

get_tables() : array

Returns

array

Return list of triggers for the current database

get_triggers() : array

Returns

array

Retrieve list of data types for the database

get_types() : array

Returns

array

Return list of views for the current database

get_views() : array

Returns

array

Create sql for batch insert

insert_batch(string $table, array $data = array()) : array

Parameters

$table

string

$data

array

Returns

array

Return the number of rows returned for a SELECT query

num_rows() : int
see

Returns

int

Create and execute a prepared statement with the provided parameters

prepare_execute(string $sql, array $params) : \Query\Driver\PDOStatement

Parameters

$sql

string

$params

array

Returns

Simplifies prepared statements for database queries

prepare_query(string $sql, array $data) : \Query\Driver\PDOStatement

Parameters

$sql

string

$data

array

Exceptions

\Query\Driver\InvalidArgumentException

Returns

\Query\Driver\PDOStatementPDOStatement / FALSE

Surrounds the string with the databases identifier escape characters

quote_ident(mixed $ident) : string

Parameters

$ident

mixed

Returns

string

Quote database table name, and set prefix

quote_table(string $table) : string

Parameters

$table

string

Returns

string

Empty the passed table

truncate(string $table) : void

Parameters

$table

string

Sets the table prefix on the passed string

_prefix(string $str) : string

Parameters

$str

string

Returns

string

 Properties

 

Last query executed

$last_query : string

Default

 

Reference to sql class

$sql : \Query\Driver\SQL_Interface

Default

 

Prefix to apply to table names

$table_prefix : string

Default

''
 

Reference to util class

$util : \Query\Driver\DB_Util

Default

 

Character to escape indentifiers

$escape_char : string

Default

'"'
 

Reference to the last executed query

$statement : \Query\Driver\PDOStatement

Default