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

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

laiz/laiz-db
============

Object relational mapping library

v1.0.3(12y ago)0442MITPHPPHP &gt;=5.3.3

Since Apr 16Pushed 11y ago1 watchersCompare

[ Source](https://github.com/nishimura/laiz-db)[ Packagist](https://packagist.org/packages/laiz/laiz-db)[ Docs](https://github.com/nishimura/laiz-db)[ RSS](/packages/laiz-laiz-db/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (5)Used By (2)

laiz-db: PHP O/R Mapping Library
================================

[](#laiz-db-php-or-mapping-library)

Simple O/R Mapping library with PHP5.

Sample Database
---------------

[](#sample-database)

Tables:

```
CREATE TABLE item (
  item_id serial primary key,
  name    text not null,
  opt     text
);
CREATE TABLE sub_item (
  sub_item_id serial primary key,
  item_id     int references item(item_id),
  name        text not null
);

```

Usage
-----

[](#usage)

Initialization::

```
$db = new Laiz\Db\Db();
$db->setDsn('pgsql:host=localhost dbname=mydb user=myuser password=pass')
    ->setConfigFile('writable/config.ini');
    ->setAutoConfig(true)
    ->setVoPrefix('Vo_');

```

Selection:

```
$item = $db->from('Item')
    ->eq(array('name' => 'Name 1'))
    ->result();
$itemAndSubItems = $db->from('Item')
    ->join('SubItem')
    ->eq(array('Item.name' => 'Name 1'))
    ->result();
$items = $db->from('Item')
    ->like(array('Item.name', 'a'))
    ->order('itemId')
    ->iterator();

```

Update:

```
$item->name = 'Item 2';
$db->save($item);

```

Insert:

```
$subItem = $db->generateVo('SubItem');
$subItem->itemId = $item->itemId;
$subItem->name = 'Sub Name 1';
$db->save($subItem);

```

Delete:

```
$db->delete($subItem);

```

Pager:

```
$pager = new Laiz\Db\Pager($items, 10);
$pagerHtml = $pager->getHtml();

```

Notice
------

[](#notice)

Vo that returned from iterator have references of variables. The following code works as expected:

```
$iterator = $db->from('Goods')->iterator();
$sum = 0;
foreach ($iterator as $goods){
    $sum += $goods->price;
}
echo $sum;

```

But, the following code does not work as expected:

```
$iterator = $db->from('Goods')->iterator();
$arr = array();
foreach ($iterator as $goods){
    $arr[] = $goods;
}
$sum = 0;
foreach ($arr as $goods){
    $sum += $goods->price;
}
echo $sum;

```

If you save vo to arrays or other variables, you need call setCloneVo method:

```
$iterator = $db->from('Goods')->iterator()->setCloneVo(true);
$arr = array();
foreach ($iterator as $goods){
    $arr[] = $goods;
}

```

...

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

4584d ago

### Community

Maintainers

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

---

Top Contributors

[![nishimura](https://avatars.githubusercontent.com/u/146196?v=4)](https://github.com/nishimura "nishimura (61 commits)")

---

Tags

databaseorm

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony1/doctrine1

PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2

40581.8k](/packages/friendsofsymfony1-doctrine1)[icanboogie/activerecord

ActiveRecord Object-relational mapping

135.0k3](/packages/icanboogie-activerecord)[andreagroferreira/laravel-sync-tracker

A Laravel package for tracking entity synchronization status between systems

113.0k](/packages/andreagroferreira-laravel-sync-tracker)

PHPackages © 2026

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