PHPackages                             phore/dba - 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. phore/dba

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

phore/dba
=========

Database abstraction layer and ORM

0126PHP

Since Jul 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phore/phore-dba)[ Packagist](https://packagist.org/packages/phore/dba)[ RSS](/packages/phore-dba/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Phore Dba (DatabaseAbstraction)
===============================

[](#phore-dba-databaseabstraction)

TL;DR;
------

[](#tldr)

Phore-dba is a very simple Object-Relational Mapper for PHP 7.

It will map Objects to Tables using exact the same Names.

- It will work with mysqli, sql, and PDO in gerneral.
- Update only changed properties
- [See sqlite3 example](examples/sqlite-create-table.php)

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

[](#installation)

Install using composer:

```
composer require phore/dba

```

Example
-------

[](#example)

- Create as Entity Class `SomeEntity` and define `__META__` data
- Initialize a Sqlite Connection to `/path/to/sqlite.db3`
- Create a Table `SomeEntity`
- Insert a new Entity for `name: someName` and `company: SomeCompany`
- `query()` all Entities and map them back to Entity using `each(callable $fn)`
- `update()` each entity, then `delete()` it (hm - it's just a demo)

```
class SomeEntity {
    use Entity;
    const __META__ = [ "primaryKey" => "id" ];
    public $id;
    public $name;
    public $company;
}

$odb = PhoreDba::InitDSN("sqlite:/path/to/sqlite.db3");
// Use multi_query() to execute multiple Statements
$odb->multi_query ("CREATE TABLE IF NOT EXISTS SomeEntity (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT,
    company TEXT
);");

$odb->insert(new SomeEntity(["name"=>"someName", "company"=>"SomeCompany"]));

$odb->query("SELECT * FROM SomeEntity WHERE name=?", ["UnescapedValue"])->each(
    function (array $row) use ($odb) {
        print_r ($entity = SomeEntity::Load($row["id"]);
        $entity->name = "MyNewName";
        $odb->update($entity);
        $odb->delete($entity);
    }
);
```

Loading from Database
---------------------

[](#loading-from-database)

```
$entity = $odb->load(SomeEntity::class, 103878);
```

or - with object casting (IDE Code-Completion):

```
$entity = SomeEntity::Load(103878);
```

Working with entities
---------------------

[](#working-with-entities)

Entities must be loaded calling the `load()` method, so the framework can track changes. You should use `query()` only to retrieve Id's and load the entities afterwards.

### Changed fields

[](#changed-fields)

```
$entity = SomeEntity::Load(1234); // Shortcut
$entity->name = "new Name";
assert ($enetity->isChanged("name") === true)
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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/878a384d056698a2400e4b7c8858db05a6caebb2c560e67151be36d46d58def0?d=identicon)[dermatthes](/maintainers/dermatthes)

---

Top Contributors

[![dermatthes](https://avatars.githubusercontent.com/u/13380559?v=4)](https://github.com/dermatthes "dermatthes (10 commits)")

### Embed Badge

![Health badge](/badges/phore-dba/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

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

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

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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