Wrapper for PDO with specific DB operations and more checks. Available via composer.
Instantiating:
$fqdb = new \Readdle\Database\FQDB('mysql:host=localhost;dbname=test', 'user', 'password');
// parses ~/.my.cnf
$fqdb = FQDBProvider::dbWithMyCnf($database);
// dsn example: mysql:host=127.0.0.1;dbname=database;charset=utf8mb4
$fqdb = FQDBProvider::dbWithDSN($dsn, $user, $password);
$fqdb = FQDBProvider::dbWithMySQLHostUserPasswordDatabase($host, $user, $password, $database);
$fqdb = new \Readdle\Database\FQDB('mysql:host=localhost;dbname=test', 'user', 'password');
$value = $fqdb->queryValue("SELECT 2+2");
// $value == 4
$hash = $fqdb->queryAssoc("SELECT id, content FROM idcontent WHERE id=13");
// $hash = ['id' => 13, 'content'=>'...']
// to use a custom connector you can register it before instantiating the FQDB
\Readdle\Database\FQDB::registerConnector(\Readdle\Database\ConnectorInterface $connector);
$fqdb = new \Readdle\Database\FQDB($optionSupportedByYourConnector);
FQDB has separate methods for different SQL queries. It throws exception if SQL query and method name does not match.
- insert
- delete
- replace
- update
- set
- select and show (queryValue, queryList, queryVector, queryAssoc, queryTable, queryObj, queryObjArray, queryTableCallback, queryTableGenerator, queryHash)
FQDB uses PDO named parameters with additional checks for unused parameters and unbind parameters.
For MySQL driver FQDB has optional warning reporting that emits MySQL warnings as PHP warnings.