PDO wrapper library with helpers
The Db class tracks query counts and can debug queries. It will auto-generate SQL for insert/update queries.
//connect
Db::_get()->setConfig($dbconfig)->connect();
//execute a fetch
$result = Db::_get()->fetch('SELECT * FROM `table` WHERE `col` = ?',array($col));
Any functions not shown in the reference are passed directly to PDO
Db can be and is recommended to be used as a singleton to reuse the same PDO instance.
If multiple connections are needed use a custom method of maintaining the instances.
Sets the config of the database system.
Takes an array with the following structure
$config = array(
'driver' => 'mysql'
,'database' => 'database_name'
,'host' => 'server_host'
,'port' => 'server_port'
,'user' => 'username'
,'password' => 'password'
);
Will use the current configuration and connect
Returns the current query count
Close the open PDO istance (if any)
Prepares WHERE strings to be used in queries
Insert into a table with given parameters
When $update_if_exists is set to TRUE it will perform an INSERT OR UPDATE query.
Updates a record in the database
Fetches a single row from a query and returns the result
Same as fetch but returns all results in an array
Language | php |
Version | 0.0.0 |
Git URL | https://github.com/nullivex/lib-db |
License | GPL-3.0 |
Description | PDO wrapper library with helpers |
Keywords |