PHPackages                             deepeloper/pdo-debugging - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. deepeloper/pdo-debugging

ActiveLibrary[Database &amp; ORM](/categories/database)

deepeloper/pdo-debugging
========================

PDO Debugging &amp; Benchmarking Tools

2.3.0(3y ago)47MITPHPPHP ^7.4

Since Dec 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/deepeloper/pdo-debugging)[ Packagist](https://packagist.org/packages/deepeloper/pdo-debugging)[ Docs](https://github.com/deepeloper/pdo-debugging)[ RSS](/packages/deepeloper-pdo-debugging/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

PDO Debugging &amp; Benchmarking Tools
======================================

[](#pdo-debugging--benchmarking-tools)

[![Packagist version](https://camo.githubusercontent.com/3c776393aa8759b82d17a5a996401f2b4cf94b6ac4205cc014ec8b9cff89b046/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656570656c6f7065722f70646f2d646562756767696e67)](https://packagist.org/packages/deepeloper/pdo-debugging)[![PHP from Packagist](https://camo.githubusercontent.com/1a580cbb2e664e271ea433c57c7a697906cdfdc4aa7b3791a2ca495020efb0ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64656570656c6f7065722f70646f2d646562756767696e672e737667)](http://php.net/)[![GitHub license](https://camo.githubusercontent.com/1ee46cc722a140bba6392e28f2a5c580f1d8277f285f53c4c19af219d2ceb78d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64656570656c6f7065722f70646f2d646562756767696e672e737667)](https://github.com/deepeloper/pdo-debugging/blob/master/LICENSE)[![GitHub issues](https://camo.githubusercontent.com/584336fae874d0705c726dff16714f7d08eb89bca7f6a7bdb91ecfd6b002ea7a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d7261772f64656570656c6f7065722f70646f2d646562756767696e672e737667)](https://github.com/deepeloper/pdo-debugging/issues)[![Packagist](https://camo.githubusercontent.com/65b780c4ed102e46e664c7f69f445a48734fdd6607c2d6dafd0c67966dbb66eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64656570656c6f7065722f70646f2d646562756767696e672e737667)](https://packagist.org/packages/deepeloper/pdo-debugging)

[![Donation](https://camo.githubusercontent.com/a59a69ad3d5f2b3205fc267af930d371787bc02ca5a4369f1d2556b119b28f16/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174696f6e2d566973612c2532304d6173746572436172642c2532304d61657374726f2c253230556e696f6e5061792c253230596f6f4d6f6e65792c2532302544302539432544302539382544302541302d726564)](https://yoomoney.ru/to/41001351141494)

Compatibility
-------------

[](#compatibility)

![PHP 8.0.*](https://camo.githubusercontent.com/80b48722d7c84566b68c1ef92fb1e4f4d7d415f1dfd61add7f236718bbe67c33/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302e2a2d253233374138364238) ‾‾ [![3.0.0](https://camo.githubusercontent.com/22b32c784d1fc24acf0f4974e74dc5e507bdae8cae2288cb68d0450f5688a439/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d332e302e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/3.0.0)

![PHP ^7.4](https://camo.githubusercontent.com/9a05ca8ea6675f1487aef708ba80692468cc5c5ac3294d93ddace17f3d5c1aca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545372e342d253233374138364238) ‾‾ [![2.3.0](https://camo.githubusercontent.com/7b85803322a485aa54eefb0994168ad60ead859b4c96101715399ceb8a09a71e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d322e332e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/2.3.0)

![PHP >=7.3 < 7.4](https://camo.githubusercontent.com/0f91bdb708ec5bba1c37a61e0d4b4841dbbc41079fd94d8e20511426c18d025b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e33253230253343372e342d253233374138364238) ‾‾ [![2.2.0](https://camo.githubusercontent.com/98094239e591446be7aa8060ca5b38097614d3acfb90c63b8309f1320ed3ee9a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d322e322e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/2.2.0)

![PHP >=7.2.5 < 7.3](https://camo.githubusercontent.com/f3a1d59c949cfb377a2342c507922323e060b19bb3273b0530a5a41badd1ad02/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e322e35253230253343372e332d253233374138364238) ‾‾ [![2.1.0](https://camo.githubusercontent.com/345350d84e6393a9e8cad0b215c72619a8b4a9b0f06305052dc2c52a7b11299f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d322e312e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/2.1.0)

![PHP ^7.0](https://camo.githubusercontent.com/24160e044b8d9bf4c3057f5601b29f641dde0b3692029a34f1e8ab06adc6fe45/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545372e302d253233374138364238) ‾‾ [![2.0.0](https://camo.githubusercontent.com/9bda17860b108370edefb3b0d81ef8a93ca4f64f8a05f4b2e29e26e230d1c7b6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d322e302e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/2.0.0)

![PHP ^5.6](https://camo.githubusercontent.com/abebe070e9c6608ef5211052a0434a6844166b4683f745e2e6db9eb49274c32c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545352e362d253233374138364238) ‾‾ [![1.2.0](https://camo.githubusercontent.com/804e42e637b2dc0103efcf08c29afb14b623c0f87f3064af0c3555cdf17d5522/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d312e322e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/1.2.0)

![PHP ^5.5](https://camo.githubusercontent.com/ac1882fe0c5fd22564914623e93ccf82ef37c958e737e4df47b0eec5a9e6d01c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545352e352d253233374138364238) ‾‾ [![1.1.0](https://camo.githubusercontent.com/dd0781547c3a19c34284e5d2c4717b509a1297ea81fca33408138baff652def5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d312e312e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/1.1.0)

![PHP ^5.4](https://camo.githubusercontent.com/cf5dde1a4aa40ce71a90f16a0fe9fc8ca6ea33adde3fd3b3136064aa43110d9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545352e342d253233374138364238) ‾‾ [![1.0.0](https://camo.githubusercontent.com/e40054ae6e8a89cc8d40d499a39be99ffe7633c17f8b52d347c295ca5a42c0fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d312e302e302d253233336662393530)](https://github.com/deepeloper/pdo-debugging/releases/tag/1.0.0)

Installation
------------

[](#installation)

Run `composer require deepeloper/pdo-debugging`.

Benchmarking
------------

[](#benchmarking)

Allows to collect following benchmarks per PDO connection:

- Global:
- - queries count/time;
- - preparation count/time;
- - fetching count/time;
- - commits count/time;
- - roll back count/time;
- - sum of time calling:
- - - PDO::\_\_construct();
- - - PDO::beginTransaction();
- - - PDO::commit();
- - - PDO::exec();
- - - PDO::prepare();
- - - PDO::query();
- - - PDO::rollBack();
- - - PDOStatement::execute();
- - - PDOStatement::fetch\*();
- Statement:
- - queries count/time;
- - fetching count/time;
- - sum of time calling:
- - - PDOStatement::execute();
- - - PDOStatement::fetch\*().

### Benchmarking usage

[](#benchmarking-usage)

```
use deepeloper\PDO\PDOExcavated;

$pdo = new PDOExcavated(
    $dsn,
    $username,
    $password,
    [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDOExcavated::ATTR_DEBUG => [],
    ]
);

$pdo->beginTransaction();
$stmt = $pdo->query("SELECT 1");
$stmt->fetch();
$pdo->commit();

$pdo->beginTransaction();
$stmt = $pdo->prepare("SELECT ?");
$stmt->bindValue(1, 100500, PDO::PARAM_INT);
$stmt->execute();
$stmt->fetch();
$pdo->rollBack();

echo "Global benchmarks: ";
print_r($pdo->getBenchmarks());
echo "\nStatement benchmarks: ";print_r($stmt->getBenchmarks());
echo sprintf("\nLast query: %s\n", $stmt->getLastExecutedQuery());
```

will output:

```
Global benchmarks: Array
(
    [query] => Array
        (
            [count] => 2
            [time] => ...
        )
    [prepare] => Array
        (
            [count] => 1
            [time] => ...
        )
    [fetch] => Array
        (
            [count] => 2
            [time] => ...
        )
    [commit] => Array
        (
            [count] => 1
            [time] => ...
        )
    [rollBack] => Array
        (
            [count] => 1
            [time] => ...
        )
    [total] => Array
        (
            [time] => ...
        )
)

Statement benchmarks: Array
(
    [query] => Array
        (
            [count] => 1
            [time] => ...
        )
    [fetch] => Array
        (
            [count] => 1
            [time] => ...
        )
    [total] => Array
        (
            [time] => ...
        )
)

Last query: SELECT 100500

```

Debugging
---------

[](#debugging)

Allows to process next methods calls:

- PDO::\_\_construct();
- PDO::beginTransaction();
- PDO::commit();
- PDO::exec();
- PDO::prepare();
- PDO::query();
- PDO::rollBack();
- PDOStatement::execute().

Allows to log queries with replaced placeholders from next methods:

- PDO::exec();
- PDO::query();
- PDOStatement::execute().

### Debugging usage

[](#debugging-usage)

```
use deepeloper\PDO\LoggerInterface;
use deepeloper\PDO\PDOExcavated;

class Logger implements LoggerInterface
{
    /**
     * Logs message.
     *
     * @param string $message
     * @return void
     */
    public function log($message, array $scope)
    {
        echo "$message\n";
    }
}

$dsn = "...";
$username = "...";
$password = "...";

$logger = new Logger();
$pdo = new PDOExcavated(
    $dsn,
    $username,
    $password,
    [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDOExcavated::ATTR_DEBUG => [
            'logger' => $logger,
            /**
             * Defaults.
             *
             * @see deepeloper\PDO\ExcavatingTrait::$debuggingOptions
             */
            'format' => [
                'timeStamp' => "Y-m-d H:i:s",
                'count' => "%03d",
                'precision' => "%.05f",
                'call'  => "[ %TIME_STAMP% ] [ %DSN%;user=%USER_NAME% ] [ %EXECUTION_TIME% ] [ CALL  ] [ %SOURCE%(%ARGS%) ]",
                'query' => "[ %TIME_STAMP% ] [ %DSN%;user=%USER_NAME% ] [ %EXECUTION_TIME% ] [ QUERY ] [ #%COUNT% ] [ %SOURCE% ] [ %QUERY% ]",
            ],
            'sources' => [
            ],
        ],
    ]
);

$pdo->exec("UPDATE `test` SET `foo` = 0");

$stmt = $pdo->query("SELECT 1");
$stmt->fetch();

$stmt = $pdo->prepare("SELECT ?");
$stmt->bindValue(1, 100500, PDO::PARAM_INT);
$stmt->execute();
```

will output:

```
[ ****-**-** **:**:** ] [ $dsn;user=$username ] [ *.***** ] [ CALL  ] [ PDOExcavated::__construct(["$dsn","$username"]) ]
[ ****-**-** **:**:** ] [ $dsn;user=$username ] [ *.***** ] [ QUERY ] [ #001 ] [ PDOExcavated::exec ] [ UPDATE `test` SET `foo` = 0 ]
[ ****-**-** **:**:** ] [ $dsn;user=$username ] [ *.***** ] [ QUERY ] [ #002 ] [ PDOExcavated::query ] [ SELECT 1 ]
[ ****-**-** **:**:** ] [ $dsn;user=$username ] [ *.***** ] [ CALL  ] [ PDOExcavated::prepare(["SELECT ?"]) ]
[ ****-**-** **:**:** ] [ $dsn;user=$username ] [ *.***** ] [ QUERY ] [ #003 ] [ PDOStatementExcavated::execute ] [ SELECT 100500 ]

```

If you wish to log only queries, pass following 'sources' section:

```
            'sources' => [
                "/^PDOExcavated::(?:exec|query)/",
                "/^PDOStatementExcavated::execute/",
            ],
```

If source started with "/" it will be processed like regular expression, otherwise will be compared like string.

### Customizing debugging

[](#customizing-debugging)

You can customize log message scope and process result message before logging:

```
use deepeloper\PDO\LoggerInterface;
use deepeloper\PDO\PDOExcavated;
use deepeloper\PDO\PDOStatementExcavated;

class class PDOExcavatedExtended extends PDOExcavated
{
    /**
     * Allows to customize log message scope.
     *
     * @param array &$scope
     * @return void
     * @see ExcavatingTrait::after()
     */
    protected function scope(array &$scope)
    {
        $scope['FOO'] = __METHOD__;
    }

    /**
     * Prepares query for logging.
     *
     * @param string &$query
     * @return void
     * @see ExcavatingTrait::after()
     */
    protected function prepareQueryForLogging(&$query)
    {
        // Modify query here.
    }

    /**
     * Method used to replace PDOStatementExcavated by possible child.
     *
     * @param string $template
     * @param PDOStatementExcavated $stmt
     * @return PDOStatementExcavatedExtended
     * @see self::getResultStatement()
     */
    protected function getStatement($template, PDOStatement $stmt)
    {
        return new PDOStatementExcavatedExtended($template, $this, $stmt);
    }
}

class PDOStatementExcavatedExtended extends PDOStatementExcavated
{
    /**
     * Allows to customize log message scope.
     *
     * @param array &$scope
     * @return void
     * @see ExcavatingTrait::after()
     */
    protected function scope(array &$scope)
    {
        $scope['FOO'] = __METHOD__;
    }

    /**
     * Prepares query for logging.
     *
     * @param string &$query
     * @return void
     * @see ExcavatingTrait::after()
     */
    protected function prepareQueryForLogging(&$query)
    {
        // Modify query here.
    }
}

class Logger implements LoggerInterface
{
    /**
     * Logs message.
     *
     * @param string $message
     * @param array $scope
     * @return void
     */
    public function log($message, array $scope)
    {
        echo "$message\n";
    }
}

$dsn = "...";
$username = "...";
$password = "...";

$logger = new Logger();
$pdo = new PDOExcavatedExtended(
    $dsn,
    $username,
    $password,
    [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDOExcavated::ATTR_DEBUG => [
            'logger' => $logger,
            'format' => [
                'call'  => "%FOO%",
                'query' => "%FOO%",
            ],
        ],
    ]
);

$pdo->exec("UPDATE `test` SET `bar` = ''");
$pdo->query("SELECT 1");
$stmt = $pdo->prepare("SELECT ?, ?");
$stmt->bindValue(1, 100500, PDO::PARAM_INT);
$stmt->bindValue(2, "blah");
$stmt->execute();
```

will output:

```
deepeloper\PDO\PDOExcavatedExtended::scope
deepeloper\PDO\PDOExcavatedExtended::scope
deepeloper\PDO\PDOExcavatedExtended::scope
deepeloper\PDO\PDOExcavatedExtended::scope
deepeloper\PDO\PDOStatementExcavatedExtended::scope

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

7

Last Release

1255d ago

Major Versions

1.2.0 → 2.0.02022-12-10

PHP version history (7 changes)1.0.0PHP ^5.4

1.1.0PHP ^5.5

1.2.0PHP ^5.6

2.0.0PHP ^7.0

2.1.0PHP &gt;=7.2.5 &lt;7.3

2.2.0PHP &gt;=7.3 &lt;7.4

2.3.0PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b08c1bee93473eb7b0d4f736249f68bf5c6319715ea036dbfd7532db9a0a7ecc?d=identicon)[deepeloper](/maintainers/deepeloper)

---

Top Contributors

[![donbidon](https://avatars.githubusercontent.com/u/30872013?v=4)](https://github.com/donbidon "donbidon (34 commits)")[![deepeloper](https://avatars.githubusercontent.com/u/1831371?v=4)](https://github.com/deepeloper "deepeloper (2 commits)")

---

Tags

phpdebugdatabaselibrarypdodb

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/deepeloper-pdo-debugging/health.svg)

```
[![Health](https://phpackages.com/badges/deepeloper-pdo-debugging/health.svg)](https://phpackages.com/packages/deepeloper-pdo-debugging)
```

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[soosyze/queryflatfile

The Queryflatfile is PHP library for simple database not SQL

181.0k1](/packages/soosyze-queryflatfile)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
