PHPackages                             koriym/csv-entities - 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. koriym/csv-entities

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

koriym/csv-entities
===================

A PDO mapping library that simplifies fetching and handling of one-to-many relationships

1.0.2(2y ago)2133.2k↓13.2%[1 issues](https://github.com/koriym/Koriym.CsvEntities/issues)1MITPHPPHP ^8.1

Since May 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/koriym/Koriym.CsvEntities)[ Packagist](https://packagist.org/packages/koriym/csv-entities)[ RSS](/packages/koriym-csv-entities/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (1)

Koriym.CsvEntities
==================

[](#koriymcsventities)

Efficiently manage one-to-many relationships in PDO with Koriym.CsvEntities. This library simplifies the process of fetching related tables by transforming the results into easily manageable PHP entities. Ideal for scenarios where a primary entity has multiple related sub-entities, it streamlines data handling and reduces the complexity of your code.

[Japanese](README.ja.md)

PDO - Fetching one to many related tables together
--------------------------------------------------

[](#pdo---fetching-one-to-many-related-tables-together)

Create a one-to-many entity list with Todo having multiple Memos in PDO as shown below.

### Example

[](#example)

```
SELECT todo.id AS id,
       todo.title AS title,
       memo.id AS memo_id,
       memo.body AS memo_body
FROM todo
       LEFT OUTER JOIN memo
       ON memo.todo_id = todo.id
GROUP BY todo.id;
```

Memo class

```
final class Memo
{
    public string $id,
    public string $title
}
```

Todo class

```
final class Todo
{
    public string $id,
    public string $title,
    /** @var array */
    public array $memos,
}
```

Usage
-----

[](#usage)

Change the above SQL and entity classes as follows.

```
SELECT todo.id AS id,
       todo.title AS title,
       GROUP_CONCAT(memo.id),
       GROUP_CONCAT(memo.body)
FROM todo
       LEFT OUTER JOIN memo
       ON memo.todo_id = todo.id
GROUP BY todo.id;
```

```
final class Memo
{
    public function __construct(
        public string $id,
        public string $title
    ){}
}
```

```
final class Todo
{
    /** @var array */
    public array $memos;

    public function __construct(
        public string $id,
        public string $title,
        string|null $memoIds,
        string|null $memoBodies
    ){
        $this->memos = (new CsvEntities())(Memo::class, $memoIds, $memoBodies);
    }
}
```

After `query()` SQL, fetchAll as follows.

```
$todoList = $pdo->fetchAll(PDO::FETCH_FUNC, static function (...$args) {
    return new Todo(...$args);
});
```

We get the `Todo[]` array we originally intended.

```
final class Todo
{
    public string $id,
    public string $title,
    /** @var array */
    public array $memos,
}
```

Separator can be specified。

```
$this->memos = (new CsvEntities())->get("\t", Memo::class, $memoIds, $memoBodies); // tab separator
```

Set maximum concatenation value for GROUP\_CONCAT
-------------------------------------------------

[](#set-maximum-concatenation-value-for-group_concat)

The maximum value of the concatenation process of columns using `GROUP_CONCAT` must be changed to `group_concat_max_len` in an ini file or query. (default value is 1024)

```
SET SESSION group_concat_max_len = 200000;
```

Install
-------

[](#install)

```
composer require koriym/csv-entities

```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community12

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

Total

4

Last Release

757d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.0.2PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (30 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koriym-csv-entities/health.svg)

```
[![Health](https://phpackages.com/badges/koriym-csv-entities/health.svg)](https://phpackages.com/packages/koriym-csv-entities)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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