PHPackages                             comphp/database - 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. comphp/database

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

comphp/database
===============

v0.1(1y ago)01MITPHPPHP ^8.4

Since Mar 17Pushed 1y agoCompare

[ Source](https://github.com/commonphp/database)[ Packagist](https://packagist.org/packages/comphp/database)[ RSS](/packages/comphp-database/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

comphp/database
===============

[](#comphpdatabase)

The **comphp/database** library provides a flexible, modular, and extensible way to manage database connections and execute queries in PHP. Designed to integrate seamlessly with the rest of the CommonPHP ecosystem, it supports:

- Multiple connections and drivers
- Alias-based connections
- Query profiling
- Event-dispatching for database operations
- PSR-3 logging
- Extensibility through the **comphp/extensible** library

Features
--------

[](#features)

- **Connection Management** – Centrally manage different database connections (e.g., MySQL, alias drivers, custom drivers, etc.).
- **Extensible Drivers** – Register new drivers via attributes to easily expand your supported databases.
- **Query Execution** – Execute queries with structured methods to fetch single rows, multiple rows, or scalars.
- **Transaction Handling** – Built-in methods for wrapping multiple queries in a transaction.
- **PSR-14 Events** – Emit events (`ConnectedEvent`, `QueryExecutedEvent`) for deeper integration.
- **Profiling &amp; Logging** – Enable query profiling and leverage PSR-3 for structured logs.

Installation
------------

[](#installation)

Install via Composer:

```
composer require comphp/database
```

Getting Started
---------------

[](#getting-started)

Below is a basic example using **DatabaseManager**:

```
