filisko / pdo-plus
PDO+ 扩展了 PDO 以记录所有查询。它还包括用于 Tracy 的栏面板
v4.0.2
2021-07-23 14:58 UTC
Requires
- php: >=8.0
- ext-pdo: *
Requires (Dev)
- ext-sqlite3: *
- friendsofphp/php-cs-fixer: ^2.16
- infection/infection: ^0.23.0
- php-coveralls/php-coveralls: ^2.4
- phpstan/phpstan: ^0.12.89
- phpunit/phpunit: ^9.5
- tracy/tracy: ^2.8
Suggests
- jdorn/sql-formatter: Highlights your SQL queries inside Tracy Bar Panel
- tracy/tracy: Tracy debugger. Remember this package includes a Bar Panel that shows logged SQL queries
README
PDO plus 扩展了 PDO 以记录所有查询。此包还包括用于 Tracy 的栏面板(对旧项目很有用),请参见以下结果。
版本
安装
通过 composer 安装
composer require filisko/pdo-plus
如何使用
在此示例中,我们使用两个不同的 PDO 实例仅用于展示这是可行的。
// Create an instance using PDO plus $pdoConnection1 = new \Filisko\PDOplus\PDO('mysql:host=127.0.0.1;dbname=my_db', 'my_user', 'my_pass'); $pdoConnection2 = new \Filisko\PDOplus\PDO('mysql:host=127.0.0.1;dbname=my_other_db', 'my_user', 'my_pass'); // ... our SQL queries ... // Dump logged queries of PDO connection 1 var_dump($pdoConnection1->getLog()); // --- the following code shows how to integrate with Tracy debugger // Instance for Tracy BarPanel for connection 1 $db1Panel = new \Filisko\PDOplus\Tracy\BarPanel($pdoConnection1); $db1Panel->title = "DB 1 Panel"; // Instance for Tracy BarPanel for connection 2 $db2Panel = new \Filisko\PDOplus\Tracy\BarPanel($pdoConnection2); $db2Panel->title = "DB 2 Panel"; // Enables Tracy debugger and adds panels for each connection (easy to integrate with legacy apps!) \Tracy\Debugger::enable(); \Tracy\Debugger::getBar()->addPanel($db1Panel); \Tracy\Debugger::getBar()->addPanel($db2Panel);
测试
运行测试
composer run-script test