Extends PDO class

Sets database connections to automatically use utf-8 and provides some useful debugging behaviour, lazy shortcuts etc

package dstruct_common

 Methods

Calls parent constructor and returns a PDO object set to UTF-8.

__construct(string $dbtype, string $host, string $uname, string $pwd, string $schema, integer $port, string $charset) : object

Any errors setting up the connection etc are echoed to the browser!

todo Check $dbtype has an available driver?

Parameters

$dbtype

string

Database type to access e.g. MySQL, SQLITE etc

$host

string

Hostname or IP address

$uname

string

Database user name

$pwd

string

Database password

$schema

string

Database schema to connect to

$port

integer

Port to attempt connection on

$charset

string

Characterset to use

Returns

objectPDO database object

Get the number of new statements prepared.

getNewStatementCount() : integer

Mainly useful for optimisation.

Returns

integer

Get the number of queries called.

getQueryCount() : integer

Mainly useful for optimisation.

Returns

integer

Overloads PDO::Prepare to allow counting of statements.

prepare(integer $statement, array $driver_options) 

See PDO manual for usage.

Parameters

$statement

integer

SQL statement to prepare

$driver_options

array

See PDO manual

Executes query and automatically echos any error to browser.

query(string $query) : object

Development tool.

Should not be used in a production environment in general as using prepared statements is safer and potentially faster (if statement is re-used). Remember to always escape any data which can not be trusted with PDO::quote().
Increments db::$querycount

see \DB::queryNoOverload

Parameters

$query

string

SQL string

Returns

object

Bypasses overloading of PDO::query().

queryNoOverload(string $query) : object

PDO::query() is overloaded when using the query() function of this class, so this provides a way of accessing it without the overloaded code

Parameters

$query

string

SQL Statement

Returns

object

 Properties

 

$newstatements : \unknown
 

$querycount : integer