v2.7.0
🎉 Release v2.7.0 - Major Feature Update
We're excited to announce version 2.7.0 - our biggest release yet! This version adds 8 major new features, 57 comprehensive documentation files, and significant performance improvements.
🚀 What's New
🔍 Full-Text Search
Cross-database full-text search with unified API across MySQL, PostgreSQL, and SQLite:
$results = $db->find()
->from('articles')
->where(Db::fulltextMatch(['title', 'content'], 'search term'))
->get();⚡ Query Result Caching (PSR-16)
10-1000x faster repeated queries with built-in caching support:
$db->enableCache($cache);
// First call hits database, subsequent calls use cache
$users = $db->find()->from('users')->cache(300)->get();📄 Advanced Pagination
Three pagination types for any use case:
- Full pagination - Complete with page numbers and totals
- Simple pagination - Fast, no COUNT overhead
- Cursor-based - Perfect for real-time feeds and infinite scroll
$result = $db->find()->from('posts')->paginate(1, 20);
// Returns: items, total, currentPage, lastPage, perPage🔄 Read/Write Connection Splitting
Master-replica architecture with automatic query routing and load balancing:
$db->enableReadWriteSplitting(new RoundRobinLoadBalancer());
$db->addConnection('write', ['host' => 'master.db']);
$db->addConnection('read-1', ['host' => 'replica1.db', 'type' => 'read']);
$db->addConnection('read-2', ['host' => 'replica2.db', 'type' => 'read']);
// Automatically routes to replicas
$users = $db->find()->from('users')->get();📊 Schema Introspection
Query your database structure programmatically:
$indexes = $db->indexes('users');
$foreignKeys = $db->keys('orders');
$constraints = $db->constraints('products');📤 Export Helpers
Export results to JSON, CSV, or XML with ease:
$users = $db->find()->from('users')->get();
$json = Db::toJson($users, JSON_PRETTY_PRINT);
$csv = Db::toCsv($users);
$xml = Db::toXml($users, 'users', 'user');📥 JSON File Loading
Bulk load JSON data directly into tables:
$db->find()->table('products')
->loadJson('products.json', update: true);🔀 Enhanced orderBy()
Multiple new syntax options for flexible sorting:
// Array with directions
->orderBy(['name' => 'ASC', 'created_at' => 'DESC'])
// Comma-separated string
->orderBy('name ASC, email DESC, id')
// Array with default direction
->orderBy(['name', 'email'], 'DESC')📚 Documentation
57 comprehensive documentation files (~12,600 lines) covering:
- Getting Started & Core Concepts
- Query Builder & JSON Operations
- Advanced Features (Caching, Pagination, Read/Write Splitting, Batch Processing)
- Error Handling & Helper Functions
- Best Practices & Security
- Complete API Reference
- Real-world Examples & Troubleshooting
🎯 Examples
93 working examples (31 files × 3 dialects):
- All examples tested and passing on MySQL, PostgreSQL, and SQLite
- New examples for all features added in this release
- README files in all example directories
🔧 Technical Details
- ✅ 533 tests passing (+55 new), 2,397 assertions
- ✅ 93/93 examples passing on all dialects
- ✅ PHPStan Level 8 - Zero errors
- ✅ PSR-12 compliant (php-cs-fixer)
- ✅ 100% backward compatible - No breaking changes
- ✅ SOLID principles - KISS, DRY, YAGNI
📈 Performance Improvements
- Memory-efficient generators for CSV/XML loading (handles files larger than RAM)
- Query caching support for 10-1000x speedup on repeated queries
- Optimized connection handling for read/write splitting
🔄 Changed
- Refactored file loading to use PHP generators (dramatically reduced memory usage)
- Improved code architecture (better extensibility with
protectedvisibility) - Enhanced test suite (best practices, no direct connection access)
- Restructured README with detailed feature descriptions
🐛 Fixed
- Cross-dialect compatibility in exception handling examples
- Invalid release date in CHANGELOG for v2.6.1
📦 Installation
composer require tommyknocker/pdo-database-class:^2.7🔗 Links
🙏 Thank You
Thank you to everyone using this library! Your feedback and support drive continuous improvement.
Full Changelog: v2.6.2...v2.7.0