CommonPHP's Database Library is a toolkit for database interaction and management in PHP applications. It offers a comprehensive set of features for connecting to databases, objectifying queries, executing them, and handling results efficiently.
- Connection Management: Simplifies the setup and management of database connections.
- Query Builder: Offers a fluent interface for constructing SQL queries including parameter management and dynamic query parts (SELECT * FROM {0} WHERE id=@id)
- Type Conversion: Provides an extensible system for converting between PHP types and database types.
- Exception Handling: Includes detailed exceptions for precise error handling in database operations.
The library is structured into several key components, including the Connection Manager, Query Builder, and various type converters. It also defines interfaces and contracts for extendability, alongside a suite of exceptions for robust error management.
Requires PHP 8.3 or newer and is built to integrate seamlessly with other CommonPHP libraries.
Use Composer to install:
composer require comphp/dbengine
Initialize the Connection Manager and use the Query Builder to create and execute database queries. Type converters can be used to handle complex data types, and exceptions are thrown for any errors encountered during database operations.
Custom type converters can be implemented by adhering to the provided interfaces, enhancing the library's flexibility and adaptability to different database systems and requirements.
For detailed examples and usage instructions, refer to the source code and PHPDoc comments within each component.
Contributions are welcome, following the contribution guidelines provided in the repository.
The library includes unit tests using PHPUnit. Instructions for running tests are provided, encouraging contributions to maintain high test coverage.
Licensed under the MIT License, promoting open and permissive usage in projects.