Tabusoft/DB is another DB wrapper to PDO/MySQL.
- It's simple like PDO
- Simplify the use of array values
- Configurable with factory class and configuration
You can install it with composer
$ composer require tabusoft/dbYou can directly pass an array to query to bind ? parameters.
<?php
$db = new \Tabusoft\DB\DB("localhost", 'db-name', 'username', 'password');
$qres = $db->query("SELECT *
FROM table
WHERE c1 = ?
OR c2 IN (?)
OR c3 = ?",
[
1, //c1
[3,4,5], //c2 parameter extends the placeholder as array
1 //c3
] );
echo PHP_EOL."Found: ".$qres->rowCount().PHP_EOL;
foreach($qres as $r){
dump($r);
}<?php
$config = new \Tabusoft\DB\DBFactoryConfig("localhost", 'db-name', 'username', 'password');
$db = \Tabusoft\DB\DBFactory::getInstance($config);You can add query events. Pre and Post execution:
class Event implements \Tabusoft\DB\DBEventsQueryInterface
{
public function __invoke(DB $db, $sql, array $infos)
{
dump($infos);
}
}
$db = \Tabusoft\DB\DBFactory::getInstance($config);
$db->addEvent(new Event(), DB::EVENT_PRE_QUERY);
$db->addEvent(new Event(), DB::EVENT_POST_QUERY);