PHPackages                             panique/pdo-debug - 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. panique/pdo-debug

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

panique/pdo-debug
=================

A super-simple function that returns the full SQL query from your PDO statements

0.2(11y ago)70110.9k—4.1%10[5 issues](https://github.com/panique/pdo-debug/issues)[1 PRs](https://github.com/panique/pdo-debug/pulls)3MITPHP

Since Sep 8Pushed 3y ago4 watchersCompare

[ Source](https://github.com/panique/pdo-debug)[ Packagist](https://packagist.org/packages/panique/pdo-debug)[ Docs](https://github.com/panique/pdo-debug)[ RSS](/packages/panique-pdo-debug/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (3)

pdo-debug
=========

[](#pdo-debug)

Shows the SQL query constructed by PDO. Seriously. The magic behind: A simple function that combines your parameters and the raw query. Please note that this is just an emulation, not the "real" result of PDO, but it does the job for nearly all common daily tasks. Way better than NOTHING!

Features
--------

[](#features)

- one simple global function `debugPDO($sql, $parameters)`
- works with named parameters (like ':param\_1') and question-mark-parameters (like '?')
- this repo also contains a demo .sql file for easily testing the example below

Big thanks to
-------------

[](#big-thanks-to)

Taken from here: , big big big thanks to bigwebguy () and Mike () for creating the debugQuery() function!

How to add to a project
-----------------------

[](#how-to-add-to-a-project)

As usual, require this via Composer (require-dev might be more useful as you definitely don't need this in production):

```
"require-dev": {
    "panique/pdo-debug": "0.2"
}
```

How to use
----------

[](#how-to-use)

Your PDO block probably looks like this:

```
$sql = "INSERT INTO test (col1, col2, col3) VALUES (:col1, :col2, :col3)";
```

and this, right ?

```
$query->execute(array(':col1' => $param_1, ':col2' => $param_2, ':col3' => $param_3));
```

To use this PDO logger, you'll have to rebuild the param array a little bit: Create an array that has the identifier as the key and the parameter as the value, like below: **WARNING: write this WITHOUT the colon! The keys need to be 'xxx', not ':xxx'!**

```
$parameters = array(
    'param1' => 'hello',
    'param2' => 123,
    'param3' => null
);
```

Your full PDO block would then look like:

```
$sql = "INSERT INTO test (col1, col2, col3) VALUES (:param1, :param2, :param3)";
$query = $database_connection->prepare($sql);
$query->execute($parameters);
```

Now you can debug / log the full SQL statement by using the static method `show()` of the PdoDebugger class. Make sure to pass the raw SQL statement and the parameters array that contains proper keys and values. Future releases might have a more professional way of handling this.

```
echo PdoDebugger::show($sql, $parameters);
```

The result of this example will be:

```
INSERT INTO test (col1, col2, col3) VALUES ('hello', 123, NULL)
```

Yeah!

Support the project (and others)
--------------------------------

[](#support-the-project-and-others)

Support the project by renting a server at [DigitalOcean](https://www.digitalocean.com/?refcode=40d978532a20) or just tipping a coffee at BuyMeACoffee.com. Thanks! :)

[![Buy Me A Coffee](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/panique)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.1% 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 ~80 days

Total

2

Last Release

4235d ago

### Community

Maintainers

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

---

Top Contributors

[![panique](https://avatars.githubusercontent.com/u/156321?v=4)](https://github.com/panique "panique (13 commits)")[![mmerian](https://avatars.githubusercontent.com/u/167871?v=4)](https://github.com/mmerian "mmerian (9 commits)")

---

Tags

logdebugsqlpdodebuggerlogger

### Embed Badge

![Health badge](/badges/panique-pdo-debug/health.svg)

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k6.0M77](/packages/ifsnop-mysqldump-php)[mnabialek/laravel-sql-logger

Log SQL queries in Laravel/Lumen framework

162820.6k2](/packages/mnabialek-laravel-sql-logger)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4883.1M39](/packages/aura-sqlquery)[noahheck/e_pdostatement

Drop in replacement for default PDOStatement class allowing devs to view an interpolated version of a parameterized query

5123.0k](/packages/noahheck-e-pdostatement)[paragonie/easydb

Easy-to-use database abstraction

740282.9k24](/packages/paragonie-easydb)

PHPackages © 2026

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