# \QueryAbstract_Driver

Base Database class

Extends PDO to simplify cross-database issues

## Summary

Methods
Properties
Constants
__construct()
__call()
get_last_query()
set_last_query()
get_sql()
get_util()
set_table_prefix()
prepare_query()
prepare_execute()
affected_rows()
prefix_table()
quote_table()
quote_ident()
get_schemas()
get_tables()
get_dbs()
get_views()
get_sequences()
get_functions()
get_procedures()
get_triggers()
get_system_tables()
get_columns()
get_fks()
get_indexes()
get_types()
driver_query()
num_rows()
insert_batch()
_quote()
truncate()
No public properties found
No constants found
_load_sub_classes()
_prefix()
$statement
$escape_char
$sql
$util
$last_query
$table_prefix
$has_truncate
N/A
No private methods found
No private properties found
N/A
abstract

File
  src/Query/Abstract_Driver.php
Package
  Query\Drivers
Class hierarchy
  \PDO
  \Query\Abstract_Driver
Implements
  \Query\Driver_Interface

## Tags

None found

## Properties

### $statement

    $statement : \PDOStatement

Reference to the last executed query

#### Type

\PDOStatement

#

## Tags

None found

### $escape_char

    $escape_char : string

Character to escape identifiers

#### Type

string

#

## Tags

None found

### $sql

    $sql : \Query\SQL_Interface

Reference to sql class

#### Type

\Query\SQL_Interface

#

## Tags

None found

### $util

    $util : \Query\Abstract_Util

Reference to util class

#### Type

\Query\Abstract_Util

#

## Tags

None found

### $last_query

    $last_query : string

Last query executed

#### Type

string

#

## Tags

None found

### $table_prefix

    $table_prefix : string

Prefix to apply to table names

#### Type

string

#

## Tags

None found

### $has_truncate

    $has_truncate : boolean

Whether the driver supports 'TRUNCATE'

#### Type

boolean

#

## Tags

None found

## Methods

### __construct()

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

PDO constructor wrapper

#### Parameters

string | $dsn |
string | $username |
string | $password |
array | $driver_options |

#

## Tags

None found

### __call()

    __call(string  $name, array  $args = array()) : mixed

Allow invoke to work on table object

#### Parameters

string | $name |
array | $args |

#### Returns

mixed

#

## Tags

codeCoverageIgnore |

### get_last_query()

    get_last_query() : string

Get the last sql query exexcuted

#### Returns

string

#

## Tags

None found

### set_last_query()

    set_last_query(string  $query_string) : void

Set the last query sql

#### Parameters

string | $query_string |

#

## Tags

None found

### get_sql()

    get_sql() : \Query\SQL_Interface

Get the SQL class for the current driver

#### Returns

\Query\SQL_Interface

#

## Tags

None found

### get_util()

    get_util() : \Query\Abstract_Util

Get the Util class for the current driver

#### Returns

\Query\Abstract_Util

#

## Tags

None found

### set_table_prefix()

    set_table_prefix(string  $prefix) : void

Set the common table name prefix

#### Parameters

string | $prefix |

#

## Tags

None found

### prepare_query()

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

Simplifies prepared statements for database queries

#### Parameters

string | $sql |
array | $data |

#### Throws

\InvalidArgumentException

#### Returns

\PDOStatement —

| FALSE

#

## Tags

None found

### prepare_execute()

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

Create and execute a prepared statement with the provided parameters

#### Parameters

string | $sql |
array | $params |

#### Returns

\PDOStatement

#

## Tags

None found

### affected_rows()

    affected_rows() : integer

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

#### Returns

integer

#

## Tags

None found

### prefix_table()

    prefix_table(string  $table) : string

Prefixes a table if it is not already prefixed

#### Parameters

string | $table |

#### Returns

string

#

## Tags

None found

### quote_table()

    quote_table(string  $table) : string

Quote database table name, and set prefix

#### Parameters

string | $table |

#### Returns

string

#

## Tags

None found

### quote_ident()

    quote_ident(mixed  $ident) : string

Surrounds the string with the databases identifier escape characters

#### Parameters

mixed | $ident |

#### Returns

string

#

## Tags

None found

### get_schemas()

    get_schemas() : array

Return schemas for databases that list them

#### Returns

array

#

## Tags

None found

### get_tables()

    get_tables() : array

Return list of tables for the current database

#### Returns

array

#

## Tags

None found

### get_dbs()

    get_dbs() : array

Return list of dbs for the current connection, if possible

#### Returns

array

#

## Tags

None found

### get_views()

    get_views() : array

Return list of views for the current database

#### Returns

array

#

## Tags

None found

### get_sequences()

    get_sequences() : array

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

#### Returns

array

#

## Tags

None found

### get_functions()

    get_functions() : array

Return list of functions for the current database

#### Returns

array

#

## Tags

None found

### get_procedures()

    get_procedures() : array

Return list of stored procedures for the current database

#### Returns

array

#

## Tags

None found

### get_triggers()

    get_triggers() : array

Return list of triggers for the current database

#### Returns

array

#

## Tags

None found

### get_system_tables()

    get_system_tables() : array

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

#### Returns

array

#

## Tags

None found

### get_columns()

    get_columns(string  $table) : array

Retrieve column information for the current database table

#### Parameters

string | $table |

#### Returns

array

#

## Tags

None found

### get_fks()

    get_fks(string  $table) : array

Retrieve foreign keys for the table

#### Parameters

string | $table |

#### Returns

array

#

## Tags

None found

### get_indexes()

    get_indexes(string  $table) : array

Retrieve indexes for the table

#### Parameters

string | $table |

#### Returns

array

#

## Tags

None found

### get_types()

    get_types() : array

Retrieve list of data types for the database

#### Returns

array

#

## Tags

None found

### driver_query()

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

Method to simplify retrieving db results for meta-data queries

#### Parameters

string|array|null | $query |
boolean | $filtered_index |

#### Returns

array

#

## Tags

None found

### num_rows()

    num_rows() : integer

Return the number of rows returned for a SELECT query

#### Returns

integer

#

See also

## Tags

None found

### insert_batch()

    insert_batch(string  $table, array  $data = array()) : null|\Query\array<string|array|\Query\null>

Create sql for batch insert

#### Parameters

string | $table |
array | $data |

#### Returns

null|\Query\array

#

## Tags

None found

### _quote()

    _quote(mixed  $str) : mixed

Helper method for quote_ident

#### Parameters

mixed | $str |

#### Returns

mixed

#

## Tags

None found

### truncate()

    truncate(string  $table) : \PDOStatement

Empty the passed table

#### Parameters

string | $table |

#### Returns

\PDOStatement

#

## Tags

None found

### _load_sub_classes()

    _load_sub_classes() : void

Loads the subclasses for the driver

#

## Tags

None found

### _prefix()

    _prefix(string  $str) : string

Sets the table prefix on the passed string

#### Parameters

string | $str |

#### Returns

string

#

## Tags

None found

### Abstract_Driver.php