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

ActiveStrukt-module[Database &amp; ORM](/categories/database)

strukt/pkg-db
=============

Database

0296PHP

Since May 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/struktapp/pkg-db)[ Packagist](https://packagist.org/packages/strukt/pkg-db)[ RSS](/packages/strukt-pkg-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Strukt Db
=========

[](#strukt-db)

Finders
-------

[](#finders)

```
$user = db("user", $id); // find user by id
```

#### Pop Db

[](#pop-db)

```
$user = db("user")->findOne(["username"=>$username]); // find user by username
```

#### Red Db

[](#red-db)

```
$user = db()->findOne("user", "username = ?", [$username]); // find user by username
$user = db()->findOne("user", "username = :username", ["username"=>$username]);
$user = db()->findLast("user");// find last user
$sql = "SELECT * FROM user u WHERE u.email LIKE :email";
$rs = db()->getAll($sql, filter(["email"], "gmail.com", false)); // find all gmail users
$rs = db()->findAll("user"); // find all users
$rs = sync($rs); // sync bean to model
```

Commit
------

[](#commit)

```
$user_id = commit("user", ["usename"=>"pitsolu","password"=>hashfn()("p@55w0rd")]);// add
$success = commit("user", ["password"=>hashfn()("*p@55w0rd$")], $user_id); // update
```

Transaction
-----------

[](#transaction)

```
pdo()->transact(function(){

	$role = db("role");
	$role->name = "superadmin";
	$role->save();

	$user = db("user");
	$user->username = "sadmin@tenure.com";
	$user->password = hash("sha256")("p@55w0rd!!");
	$user->role_id = "abc"; //invalid entry expect a number
	$user->save();
});
```

Commands
--------

[](#commands)

```
Database
 model:make      Make model
 db:make-models  Make models from db
 db:make         Make db from models
 db:seeds        Seed database tables iwth JSON set (folder)
 db:wipe         Truncate database
 db:sql          Truncate database
```

Resultset
---------

[](#resultset)

```
$sql = select("u.id, u.username, r.name as role_name, r.created_at")
        ->from("user u")
        ->leftjoin("role r ON r.id = u.role_id")
        ->where("r.name = :role_name")
        ->orderBy("p.name", order:"ASC");

$rs = resultset($sql, ["role_name"=>"admin"])
        ->normalize("created_at:humanize")
        ->yield(); // list of admins
```

SQL
---

[](#sql)

```
├── modify(string $table)
│   ├── addSet(string $modify)
│   ├── set(string $modify)
│   │   ├── andWhere(string $condition)
│   │   ├── orWhere(string $condition)
│   │   ├── where(string $condition)
│   │   └── yield():string
│   └── yield():string
└── select(string $fields)
    ├── addSelect(string $fields)
    ├── from(string $tables)
    │   └── leftjoin(string $join)
    ├── groupBy(string $columns)
    ├── limit(int $limit)
    ├── orderBy(string $columns, string $order = "DESC")
    ├── page(int $page, int $perPage=10)
    ├── union(string $sql)
    ├── unionAll(string $sql)
    └── where(string $condition)
        ├── andWhere(string $condition)
        └── orWhere(string $condition)
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

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/6f77a56030c77ce25f7fcf6db800e45bb6a31bf3c07740b43aeabcdf5e9edec2?d=identicon)[pitsolu](/maintainers/pitsolu)

---

Top Contributors

[![pitsolu](https://avatars.githubusercontent.com/u/16669704?v=4)](https://github.com/pitsolu "pitsolu (172 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/strukt-pkg-db/health.svg)](https://phpackages.com/packages/strukt-pkg-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)
