This class provides a genericized interface to the PHP PDO toolkit. More...
Public Member Functions | |
| __construct ( $driver, $host, $database, $user=NULL, $password=NULL, $charset=NULL) | |
| Initializes connection param class members. More... | |
| preparedExec ( $sql, $params=array()) | |
| Wrapper for preparing and executing a PDOStatement that does not return a resultset e.g. INSERT or UPDATE SQL statements. More... | |
| preparedQuery ( $sql, $params=array(), $fetchKeyPair=false) | |
| Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statements. More... | |
Public Attributes | |
| $driver_type = NULL | |
| The type of PDO driver we are configured for. More... | |
| $class_description = NULL | |
| A simple description of this class. More... | |
| $last_insert = NULL | |
| This holds the integer ID of the last AUTO_INCREMENT insert. More... | |
| $owner_instance = NULL | |
| This is the instance of A_CO_DB that "owns" this instance. We can use this for auditing. More... | |
Private Attributes | |
| $_pdo = NULL | |
| Internal PDO object. More... | |
| $fetchMode = PDO::FETCH_ASSOC | |
| Default fetch mode for internal PDOStatements. More... | |
This class provides a genericized interface to the PHP PDO toolkit.
Definition at line 32 of file co_pdo.class.php.
| CO_PDO::__construct | ( | $driver, | |
| $host, | |||
| $database, | |||
$user = NULL, |
|||
$password = NULL, |
|||
$charset = NULL |
|||
| ) |
Initializes connection param class members.
Must be called BEFORE any attempts to connect to or query a database.
Will destroy previous connection (if one exists).
| $driver | database server type (ex: 'mysql') |
| $host | database server host |
| $database | database name |
| $user | user, optional |
| $password | password, optional |
| $charset | connection charset, optional |
Definition at line 56 of file co_pdo.class.php.
| CO_PDO::preparedExec | ( | $sql, | |
$params = array() |
|||
| ) |
Wrapper for preparing and executing a PDOStatement that does not return a resultset e.g. INSERT or UPDATE SQL statements.
See PDO documentation about prepared queries.
If there isn't already a database connection, it will "lazy load" the connection.
| Exception | thrown if internal PDO exception is thrown |
| $sql | same as kind provided to PDO::prepare() |
| $params | same as kind provided to PDO::prepare() |
Definition at line 96 of file co_pdo.class.php.
| CO_PDO::preparedQuery | ( | $sql, | |
$params = array(), |
|||
$fetchKeyPair = false |
|||
| ) |
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statements.
Returns a multidimensional array depending on internal fetch mode setting ($this->fetchMode) See PDO documentation about prepared queries.
Fetching key pairs- when $fetchKeyPair is set to true, it will force the returned array to be a one-dimensional array indexed on the first column in the query. Note- query may contain only two columns or an exception/error is thrown. See PDO::PDO::FETCH_KEY_PAIR for more details
| Exception | thrown if internal PDO exception is thrown |
| $sql | same as kind provided to PDO::prepare() |
| $params | same as kind provided to PDO::prepare() |
| $fetchKeyPair | See description in method documentation |
Definition at line 149 of file co_pdo.class.php.
|
private |
Internal PDO object.
Definition at line 34 of file co_pdo.class.php.
| CO_PDO::$class_description = NULL |
A simple description of this class.
Definition at line 38 of file co_pdo.class.php.
| CO_PDO::$driver_type = NULL |
The type of PDO driver we are configured for.
Definition at line 36 of file co_pdo.class.php.
|
private |
Default fetch mode for internal PDOStatements.
Definition at line 45 of file co_pdo.class.php.
| CO_PDO::$last_insert = NULL |
This holds the integer ID of the last AUTO_INCREMENT insert.
Definition at line 40 of file co_pdo.class.php.
| CO_PDO::$owner_instance = NULL |
This is the instance of A_CO_DB that "owns" this instance. We can use this for auditing.
Definition at line 42 of file co_pdo.class.php.