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 yesterday

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

29

—

LowBetter than 57% of packages

Maintenance44

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

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

453d ago

PHP version history (2 changes)0.0.1PHP ^8.3

0.1.0PHP &gt;=8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18727603?v=4)[Ilyas](/maintainers/IlyasDeckers)[@IlyasDeckers](https://github.com/IlyasDeckers)

---

Top Contributors

[![IlyasDeckers](https://avatars.githubusercontent.com/u/18727603?v=4)](https://github.com/IlyasDeckers "IlyasDeckers (78 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

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

1.3k1.4M203](/packages/sulu-sulu)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[metamodels/core

MetaModels core

10156.4k66](/packages/metamodels-core)

PHPackages © 2026

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