PHPackages                             flytachi/winter-cdo - 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. [Framework](/categories/framework)
4. /
5. flytachi/winter-cdo

ActiveLibrary[Framework](/categories/framework)

flytachi/winter-cdo
===================

Winter framework cdo component

v1.2.5(2mo ago)2208↓30%1MITPHPPHP &gt;=8.3

Since Dec 17Pushed 2mo agoCompare

[ Source](https://github.com/Flytachi/winter-cdo)[ Packagist](https://packagist.org/packages/flytachi/winter-cdo)[ RSS](/packages/flytachi-winter-cdo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (14)Used By (1)

Winter CDO Component
====================

[](#winter-cdo-component)

[![Latest Version on Packagist](https://camo.githubusercontent.com/95ad8f778997d419bf8b2344016b11ddd11c411c5e9898d1250cd152712bc69b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c7974616368692f77696e7465722d63646f2e737667)](https://packagist.org/packages/flytachi/winter-cdo)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)

CDO (Connection Data Object) — an extended PDO wrapper for convenient database operations.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3
- ext-pdo
- flytachi/winter-base ^1.0

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

[](#installation)

```
composer require flytachi/winter-cdo
```

Supported Databases
-------------------

[](#supported-databases)

DatabaseinsertinsertGroupupsertupsertGroupupdatedeletePostgreSQL✅✅✅✅✅✅MySQL/MariaDB✅✅✅✅✅✅Oracle⚠️✅❌❌✅✅Quick Start
-----------

[](#quick-start)

### 1. Create a Configuration

[](#1-create-a-configuration)

```
use Flytachi\Winter\Cdo\Config\PgDbConfig;

class MyDbConfig extends PgDbConfig
{
    public function setUp(): void
    {
        $this->host = env('DB_HOST', 'localhost');
        $this->port = (int) env('DB_PORT', 5432);
        $this->database = env('DB_NAME', 'mydb');
        $this->username = env('DB_USER', 'postgres');
        $this->password = env('DB_PASS', '');
        $this->schema = env('DB_SCHEMA', 'public');
    }
}
```

### 2. Get a Connection

[](#2-get-a-connection)

```
use Flytachi\Winter\Cdo\ConnectionPool;

$cdo = ConnectionPool::db(MyDbConfig::class);
```

### 3. Perform Operations

[](#3-perform-operations)

```
use Flytachi\Winter\Cdo\Qb;

// Insert
$id = $cdo->insert('users', [
    'name' => 'John',
    'email' => 'john@example.com'
]);

// Update
$affected = $cdo->update('users', ['name' => 'Jane'], Qb::eq('id', 1));

// Delete
$deleted = $cdo->delete('users', Qb::eq('id', 1));
```

API Reference
-------------

[](#api-reference)

### CDO Methods

[](#cdo-methods)

#### `insert(string $table, object|array $entity): mixed`

[](#insertstring-table-objectarray-entity-mixed)

Insert a single record. Returns the inserted record ID.

```
$userId = $cdo->insert('users', [
    'name' => 'John',
    'email' => 'john@example.com'
]);
```

#### `insertGroup(string $table, array $entities, int $chunkSize = 1000): void`

[](#insertgroupstring-table-array-entities-int-chunksize--1000-void)

Batch insert with automatic chunking.

```
$users = [
    ['name' => 'John', 'email' => 'john@example.com'],
    ['name' => 'Jane', 'email' => 'jane@example.com'],
    // ... thousands of records
];

$cdo->insertGroup('users', $users);
$cdo->insertGroup('users', $users, chunkSize: 500); // custom chunk size
```

#### `upsert(string $table, object|array $entity, array $conflictColumns, ?array $updateColumns = null): mixed`

[](#upsertstring-table-objectarray-entity-array-conflictcolumns-array-updatecolumns--null-mixed)

Insert or update a single record.

```
// Insert or update
$cdo->upsert(
    'products',
    ['sku' => 'ABC', 'name' => 'Product', 'price' => 100],
    ['sku'],
    ['name' => ':new', 'price' => ':new']
);

// Insert only (ignore duplicates)
$cdo->upsert('users', $user, ['email']);
```

#### `upsertGroup(string $table, array $entities, array $conflictColumns, ?array $updateColumns = null, int $chunkSize = 500): void`

[](#upsertgroupstring-table-array-entities-array-conflictcolumns-array-updatecolumns--null-int-chunksize--500-void)

Batch upsert with automatic chunking.

```
$cdo->upsertGroup(
    'inventory',
    $items,
    ['warehouse_id', 'product_id'],
    [
        'cost' => ':new',
        'quantity' => ':current + :new',
        'updated_at' => 'NOW()'
    ]
);
```

**Placeholders**

PlaceholderPostgreSQLMySQL`:new``EXCLUDED.column``VALUES(column)``:current``table.column``column`**Expression Examples**

ExpressionDescription`:new`Replace with new value`:current + :new`Add to current value`GREATEST(:current, :new)`Take maximum`COALESCE(:new, :current)`New value or keep current`NOW()`SQL function (no placeholder)#### `update(string $table, object|array $entity, Qb $qb): int`

[](#updatestring-table-objectarray-entity-qb-qb-int)

Update records by condition. Returns the number of affected rows.

```
$affected = $cdo->update(
    'users',
    ['status' => 'inactive'],
    Qb::and(
        Qb::lt('last_login', '2024-01-01'),
        Qb::eq('status', 'active')
    )
);
```

#### `delete(string $table, Qb $qb): int`

[](#deletestring-table-qb-qb-int)

Delete records by condition. Returns the number of deleted rows.

```
$deleted = $cdo->delete('sessions', Qb::lt('expires_at', date('Y-m-d H:i:s')));
```

### Qb (Query Builder)

[](#qb-query-builder)

WHERE condition generator with automatic SQL injection protection.

#### Comparison Operators

[](#comparison-operators)

```
Qb::eq('status', 'active')     // status = ?
Qb::neq('status', 'deleted')   // status != ?
Qb::gt('age', 18)              // age > ?
Qb::geq('age', 18)             // age >= ?
Qb::lt('age', 65)              // age < ?
Qb::leq('age', 65)             // age = ?) OR (role = ? AND department IN (?, ?))) AND email_verified_at IS NOT NULL
```

### ConnectionPool

[](#connectionpool)

Connection manager with caching.

```
// Get connection (created once, then reused)
$cdo = ConnectionPool::db(MyDbConfig::class);

// Get config
$config = ConnectionPool::getConfigDb(MyDbConfig::class);

// Check connection
$config->ping();        // bool
$config->pingDetail();  // ['status' => bool, 'latency' => float, 'error' => ?string]

// Reconnect
$config->reconnect();
```

### Configurations

[](#configurations)

#### PostgreSQL

[](#postgresql)

```
use Flytachi\Winter\Cdo\Config\PgDbConfig;

class MyPgConfig extends PgDbConfig
{
    public function setUp(): void
    {
        $this->host = 'localhost';
        $this->port = 5432;
        $this->database = 'mydb';
        $this->username = 'postgres';
        $this->password = 'secret';
        $this->schema = 'public';
        $this->charset = 'UTF8';        // optional
        $this->isPersistent = false;    // optional
    }
}
```

#### MySQL / MariaDB

[](#mysql--mariadb)

```
use Flytachi\Winter\Cdo\Config\MySqlDbConfig;

class MyMySqlConfig extends MySqlDbConfig
{
    public function setUp(): void
    {
        $this->host = 'localhost';
        $this->port = 3306;
        $this->database = 'mydb';
        $this->username = 'root';
        $this->password = 'secret';
        $this->charset = 'utf8mb4';     // optional
        $this->isPersistent = false;    // optional
    }
}
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance92

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

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 ~6 days

Total

13

Last Release

68d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/861b81dd97c8ddfa919522d2a4e17626120bd3e3d7464857cc03784676bc74a8?d=identicon)[Flytachi](/maintainers/Flytachi)

---

Top Contributors

[![Flytachi](https://avatars.githubusercontent.com/u/68924300?v=4)](https://github.com/Flytachi "Flytachi (20 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/flytachi-winter-cdo/health.svg)

```
[![Health](https://phpackages.com/badges/flytachi-winter-cdo/health.svg)](https://phpackages.com/packages/flytachi-winter-cdo)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M255](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M119](/packages/cakephp-chronos)

PHPackages © 2026

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