Merged
Conversation
- Created detailed database performance analysis comparing MySQL, PostgreSQL, MariaDB and SQLite - Added benchmark results showing throughput and latency for different database operations - Documented PDO configuration and optimization strategies for each database - Included real-world performance metrics with Express PHP framework overhead analysis - Updated documentation indices to include database performance section - Added code examples demonstrating PDO usage with prepared statements Key insights: - SQLite shows best performance for small/medium applications - MariaDB outperforms MySQL in most scenarios - PostgreSQL excels at complex queries - Connection pooling provides 40%+ improvement for relational databases - Express PHP adds minimal overhead (<0.2ms average) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…s PHP v2.1.3 - Introduced PERFORMANCE_SUMMARY.md for detailed performance metrics. - Updated existing PERFORMANCE_SUMMARY.md with new test results and metrics. - Created run_all_benchmarks.php to automate benchmark execution and reporting. - Added docker-compose.benchmark.yml for a complete benchmarking environment setup. - Developed PERFORMANCE_COMPARISON.md to track performance evolution across versions. - Generated PERFORMANCE_REPORT_v2.1.3.md for a detailed analysis of v2.1.3 performance. - Updated README.md in benchmarks to reflect the latest performance results. - Revised FRAMEWORK_OVERVIEW_v2.1.3.md to include current performance metrics. - Implemented PDOConnection.php for database interactions in benchmarks. - Added DatabaseException.php for handling database-related errors.
- Fix getInstance() to properly handle null instance case by throwing DatabaseException - Fix lastInsertId() to handle false return value from PDO - Add proper exception handling and type safety - Maintains backward compatibility while ensuring type correctness This resolves the PHPStan Level 9 errors reported in GitHub Actions.
- Move PDO::MYSQL_ATTR_USE_BUFFERED_QUERY to driver-specific configuration - Ensure common PDO options are applied to all drivers - Add comprehensive unit tests for driver-specific configurations - Prevent errors when using PostgreSQL, SQLite, or other non-MySQL drivers This fixes potential errors when using PDOConnection with non-MySQL databases.
- Check for PDO::MYSQL_ATTR_USE_BUFFERED_QUERY and PDO::MYSQL_ATTR_COMPRESS constants before use - Fix array merge to preserve numeric PDO constant keys - Update tests to skip MySQL-specific assertions when extension is not available - Fix PSR-12 compliance issues (trailing whitespace, EOF newlines) - Ensure PDOConnection works with SQLite when MySQL extension is not present This allows the framework to work properly in environments where only specific PDO drivers are installed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove appended PDO error message from connection failure to match test - Test expects exact message 'Database connection failed' without details - The previous exception is still passed for debugging via stack trace 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace array union operator (+) with array_replace() for clarity - array_replace() explicitly shows user options take precedence - More intuitive behavior: defaults are replaced by user options - Preserves numeric PDO constant keys correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Reset both instance and config in close() method - Prevents stale configuration from persisting after connection close - Add test to verify configuration is properly cleared - Ensures clean state for subsequent connections This prevents potential bugs where old configuration could affect new connections after calling close(). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add support for 'collation' configuration key in PDO options - Set collation via PDO::MYSQL_ATTR_INIT_COMMAND for MySQL/MariaDB - Add proper checks for MySQL extension constants availability - Create comprehensive tests for collation setting functionality - Handle cases where MySQL PDO extension is not available The 'collation' configuration key was previously unused. This change ensures it's properly applied when connecting to MySQL/MariaDB databases via the SET NAMES command with COLLATE clause. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR delivers a new singleton-based PDOConnection manager (with DatabaseException), full PHPUnit coverage for its configuration/connect/query methods, and a major update of performance documentation and Docker-based benchmarking setup targeting v2.1.3.
- Added
src/Database/PDOConnection.phpandsrc/Exceptions/DatabaseException.phpfor unified PDO handling. - Introduced comprehensive PHPUnit tests in
tests/Database/PDOConnectionTest.php. - Updated release notes, performance metrics, benchmark docs, and Docker configurations for version 2.1.3.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Database/PDOConnectionTest.php | Adds unit tests for driver-specific and common PDO configuration. |
| src/Exceptions/DatabaseException.php | Defines a custom exception for database errors. |
| src/Database/PDOConnection.php | Implements singleton PDO manager with driver options and utilities. |
| docs/releases/README.md | Bumps version and last-updated date for v2.1.3. |
| docs/performance/* | Refreshes performance metrics, comparison tables, and reports. |
| docker-compose.benchmark.yml & Dockerfile.benchmark | Sets up standardized Docker benchmarking environment and scripts. |
Comments suppressed due to low confidence (4)
docs/releases/FRAMEWORK_OVERVIEW_v2.1.3.md:40
- The response creation metric here (2.27M ops/sec) doesn’t match the 2.58M ops/sec reported in PERFORMANCE_REPORT_v2.1.3; please reconcile these values for consistency.
- **2.27M ops/sec** - Response Object Creation
docs/performance/PERFORMANCE_COMPARISON.md:11
- The improvement column shows "+14x" for v2.1.3 vs v2.0.1 but the ops/s values suggest a different ratio; please verify and correct the improvement percentage.
| **Response Creation** | 2.58M ops/s | 2.69M ops/s | 24M ops/s* | 18M ops/s | +14x |
src/Database/PDOConnection.php:256
- There’s no unit test covering
getStats()—consider adding a test to verify that returned driver, version, and status attributes are correct.
public static function getStats(): array
src/Exceptions/DatabaseException.php:16
- [nitpick] The constructor only calls the parent without modification—consider removing it for brevity, relying on the inherited constructor behavior.
public function __construct(string $message = "", int $code = 0, ?Exception $previous = null)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
📋 Descrição
Descreva resumidamente as mudanças feitas neste PR.
🎯 Tipo de Mudança
🧪 Como foi testado?
Descreva os testes que você executou para verificar suas mudanças.
📝 Checklist