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

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

ody/database
============

Database package for ody API framework

0.2.0(1y ago)038[1 PRs](https://github.com/ody-dev/database/pulls)2MITPHPPHP &gt;=8.3CI failing

Since Mar 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (8)Versions (10)Used By (2)

ODY database module
===================

[](#ody-database-module)

⚠️ **IMPORTANT**: This repository is automatically generated from the [ody repo](https://github.com/ody-dev/ody) and is read-only.

A high-performance database integration framework for PHP applications leveraging Swoole's coroutines.

Overview
--------

[](#overview)

The ODY Database module provides a connection pool implementation that works with popular PHP ORM solutions. It's designed to maximize performance in Swoole environments by efficiently managing database connections across coroutines.

Features
--------

[](#features)

- Connection pooling with Swoole coroutine awareness
- Support for Doctrine ORM, and standalone DBAL
- Automatic connection binding to coroutines
- Built-in connection lifecycle management
- Connection health checks and leak detection
- Configurable pool size and connection settings

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

[](#installation)

```
composer require ody/database
```

### Doctrine ORM

[](#doctrine-orm)

```
composer require doctrine/orm doctrine/dbal symfony/cache
```

### DBAL

[](#dbal)

```
composer require doctrine/dbal
```

Basic Usage
-----------

[](#basic-usage)

### Configuration

[](#configuration)

Define your database configuration:

```
// config/database.php
return [
    'environments' => [
        'local' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'port' => 3306,
            'database' => 'your_database',
            'username' => 'your_username',
            'password' => 'your_password',
            'charset' => 'utf8mb4',
        ],
    ],
    'connection_pool_enabled' => true,
    'pool_size' => 10,
];
```

### Using with Doctrine ORM

[](#using-with-doctrine-orm)

```
use Ody\DB\Doctrine\Facades\ORM;
use App\Entities\User;

// Get entity manager
$entityManager = ORM::entityManager();

// Working with entities
$user = $entityManager->find(User::class, 1);
$entityManager->persist($user);
$entityManager->flush();
```

### Using with Doctrine DBAL

[](#using-with-doctrine-dbal)

```
use Ody\DB\Doctrine\Facades\DBAL;

// Execute queries
$users = $this->connection->fetchAllAssociative('SELECT * FROM users WHERE active = ?', [1]);

// Using query builder
$queryBuilder = $this->connection->createQueryBuilder();
$result = $queryBuilder
    ->select('u.*')
    ->from('users', 'u')
    ->where('u.active = :active')
    ->setParameter('active', 1)
    ->executeQuery()
    ->fetchAllAssociative();
```

### Direct Connection Pool Access

[](#direct-connection-pool-access)

```
use Ody\DB\ConnectionManager;

// Initialize the pool
ConnectionManager::initPool($config);

// Get a connection from the pool
$connection = ConnectionManager::getConnection();

// Use the PDO connection
$stmt = $connection->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([1]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);

// No need to return the connection - it's automatically returned when the coroutine ends
```

Advanced Configuration
----------------------

[](#advanced-configuration)

The connection pool can be finely tuned with options for:

- Minimum idle connections
- Idle timeout
- Maximum connection lifetime
- Borrowing timeout
- Connection health checks
- Leak detection threshold

For detailed documentation on advanced configuration and usage, refer to the full documentation.

Performance Benefits
--------------------

[](#performance-benefits)

- Connections are reused across requests, eliminating the overhead of establishing new connections
- Automatic binding to coroutines ensures connection safety in concurrent environments
- Connection health checks prevent using broken connections
- Leak detection helps identify and fix connection leaks
- Configurable pool size matches your application needs and server resources

License
-------

[](#license)

This package is licensed under the [MIT License](https://github.com/ody-dev/ody-foundation/blob/master/LICENSE).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance47

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

8

Last Release

406d ago

PHP version history (2 changes)0.0.1PHP ^8.3

0.1.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/984734252c6b932be5ef737920c3d0f792283664e75ba405f3df268cc1da138c?d=identicon)[IlyasDeckers](/maintainers/IlyasDeckers)

---

Top Contributors

[![IlyasDeckers](https://avatars.githubusercontent.com/u/18727603?v=4)](https://github.com/IlyasDeckers "IlyasDeckers (77 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ody-database/health.svg)

```
[![Health](https://phpackages.com/badges/ody-database/health.svg)](https://phpackages.com/packages/ody-database)
```

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
