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 2w 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 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity20

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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

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

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

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