-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Hi @ThingEngineer and contributors! 👋
I wanted to reach out and share something with the community. Years ago, I was inspired by this excellent library to create my own database abstraction layer. Over time, it evolved significantly, and I recently modernized it for PHP 8.4+.
🙏 Credit Where Credit's Due
This project (PHP-MySQLi-Database-Class) was the original inspiration that got me started. Your clean API design and practical approach to database abstraction influenced how I think about these problems. Thank you for creating and maintaining this resource!
🚀 What I Built: PDOdb
Repository: https://github.com/tommyknocker/pdo-database-class
Packagist: https://packagist.org/packages/tommyknocker/pdo-database-class
While the API has diverged significantly over the years, the core philosophy remains: make database operations simple, safe, and enjoyable.
✨ Key Differences & Features
- Multi-database support: MySQL, PostgreSQL, and SQLite with unified API
- Modern PHP 8.4+: Property hooks, union types, match expressions
- Fluent QueryBuilder: Expressive, chainable syntax
- Comprehensive JSON support: Native JSON operations across all databases
- 20+ SQL helper functions: Math, string, date/time operations
- Connection pooling: Similar to this project, with multi-database support
- Zero external dependencies: Just PDO and PSR-3 logging
- Fully tested: 246 tests, 1296 assertions across all three databases
📚 Live Examples
We've created 18 comprehensive, runnable examples covering everything from basic CRUD to complex multi-database architectures. Check out the examples/ directory:
- Basic: Connection, CRUD, WHERE conditions, INSERT/UPDATE
- Intermediate: JOINs, aggregations, pagination, transactions
- Advanced: Connection pooling, bulk operations, UPSERT
- JSON: Complete guide to JSON features
- Helpers: String, math, date/time, NULL handling
- Real-World: Full blog system with posts, comments, and tags
Each example is self-contained, tested, and ready to run!
📖 Example
use tommyknocker\pdodb\PdoDb;
use tommyknocker\pdodb\helpers\Db;
$db = new PdoDb('mysql', [
'host' => 'localhost',
'username' => 'user',
'password' => 'pass',
'dbname' => 'testdb'
]);
// Fluent API with JSON support
$adults = $db->find()
->from('users')
->where('age', 18, '>')
->andWhere(Db::jsonContains('tags', 'php'))
->orderBy('created_at', 'DESC')
->limit(10)
->get();
// Multi-database connection pooling
$db = new PdoDb();
$db->addConnection('mysql_main', ['driver' => 'mysql', ...]);
$db->addConnection('pgsql_analytics', ['driver' => 'pgsql', ...]);
$users = $db->connection('mysql_main')->find()->from('users')->get();
$stats = $db->connection('pgsql_analytics')->find()->from('stats')->get();🎯 Why Share This?
I believe both libraries serve different use cases and can coexist:
- PHP-MySQLi-Database-Class: Battle-tested, stable, MySQLi-based, excellent for PHP 7.x+ projects and MySQL applications
- PDOdb: Modern PHP 8.4+, multi-database (MySQL/PostgreSQL/SQLite), ideal for projects requiring cross-database compatibility
If anyone here is looking for multi-database support, PostgreSQL/SQLite compatibility, or wants to leverage modern PHP 8.4 features, PDOdb might be worth checking out. And if you're happy with this library (which is excellent!), absolutely stick with it!
📖 Resources
- Documentation: Comprehensive README with 1400+ lines
- Examples: 18 runnable examples
- CHANGELOG: Full history from v1.0.3 to v2.5.0
- Installation:
composer require tommyknocker/pdo-database-class
TL;DR: Built a modern, multi-database alternative inspired by this project. Wanted to say thanks and share with folks who might find it useful! 🙂
Feel free to close this issue if it's not appropriate - just wanted to give credit and potentially help some community members who might be looking for these features.