PHPackages                             myth/db - 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. myth/db

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

myth/db
=======

An effortless database abstraction built on top of CodeIgniter 4.

411PHP

Since Jan 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lonnieezell/myth-db)[ Packagist](https://packagist.org/packages/myth/db)[ RSS](/packages/myth-db/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Myth:db
=======

[](#mythdb)

Myth:db is an exploration of a possible new database layer for CodeIgniter 4. It adds a reflective Data Mapper to make getting data as simple as possible. While it uses Models and Entities in the background, it can be used with almost zero setup or code generation.

Examples
--------

[](#examples)

### Getting all results in a table

[](#getting-all-results-in-a-table)

The basic usage is with the `map()` method, which takes the name of the table you want to work with. It then creates a generic model, assigns the table name, inspects the table to populate the model's properties, and returns the model. Since you have a model, you then have access to the model methods, such as `findAll()`, and the Query Builder methods, such as `where()`.

```
$users = db()->map('users')->findAll();
```

By default, this would return an array of objects, one for each of the rows in the table. If you would like to change the return type, you can pass in the name of the class, `array`, or `object` with the `returns()` method.

```
$users = db()->map('users')->returns('array')->findAll();
$users = db()->map('users')->returns(\App\Entities\User::class)->findAll();
```

### Custom Entities

[](#custom-entities)

You can create your own Entities and the mapper will automatically return results in that format. This is all based on conventions. By default, it would look for an entity named `User` in the `App\Entities` namespace. The name of the Entity is the singular, PascalCase version of the table name.

```
// If App\Entities\User exists, all results will be returned as User objects
// otherwise, each record will be returned as an object.
$users = db()->map('users')->findAll();

// Would return each result as instance of App\Entities\ZodiacSign, if it exists.
$signs = db()->map('zodiac_signs')->findAll();
```

### Custom Models

[](#custom-models)

You can also create your own Models and the mapper will automatically use that instead of the default Model. This is also based on conventions. It would look for a model named the PascalCase singular version of the table name, with `Model` appended to it.

```
// Will look for App\Models\UserModel
$users = db()->map('users')->findAll();

// Will look for App\Models\ZodiacSignModel
$signs = db()->map('zodiac_signs')->findAll();
```

NOTE: Returns an iterable cursor for better memory?

TODO: Return findX results as a collection?

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/65f693f45781e767ed8557b776fd775309e7a262629892b99cf38462931e9b26?d=identicon)[lonnieezell](/maintainers/lonnieezell)

---

Top Contributors

[![lonnieezell](https://avatars.githubusercontent.com/u/51931?v=4)](https://github.com/lonnieezell "lonnieezell (1 commits)")

### Embed Badge

![Health badge](/badges/myth-db/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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