PHPackages                             walnut/lib\_dbquery - 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. walnut/lib\_dbquery

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

walnut/lib\_dbquery
===================

0.0.5(2y ago)0942PHP

Since Sep 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kapitancho/walnut-lib-dbquery)[ Packagist](https://packagist.org/packages/walnut/lib_dbquery)[ RSS](/packages/walnut-lib-dbquery/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (2)

Database Query basics
=====================

[](#database-query-basics)

A simple abstraction over queries and execution

Using queries:
--------------

[](#using-queries)

### Fixed Query

[](#fixed-query)

```
$query = new FixedQuery("SELECT * FROM users WHERE is_active = 1");
$result = $query->execute($queryExecutor);
$result->all(); //all active users
```

### Prepared Query

[](#prepared-query)

```
$query = new PreparedQuery("SELECT * FROM users WHERE id = :id", ['id']);
$result = $query->execute($queryExecutor, ['id' => 5]);
$result->first(); //user with id 5 (or null if it does not exist)
```

### Placeholder Query

[](#placeholder-query)

```
$query = new Placeholder("SELECT * FROM users WHERE name LIKE **__name__**", ['name']);
$result = $query->execute($queryExecutor, null, ['name' => '%john%']);
$result->all(); //all user with name including "john"
```

Using result bags:
------------------

[](#using-result-bags)

### List Result Bag

[](#list-result-bag)

```
$bag = new ListResultBag([
    1 => ['id' => 1, 'name' => 'Name 1'],
    2 => ['id' => 2, 'name' => 'Name 2'],
    3 => ['id' => 3, 'name' => 'Name 3'],
]);
$bag->all(); //3 items
$bag->withKey(1); //['id' => 1, 'name' => 'Name 1']
$bag->withKey(5); //null
$bag->collect('name'); //['Name 1', 'Name 2', 'Name 3']
```

### Tree Data Result Bag

[](#tree-data-result-bag)

```
$bag = new TreeDataResultBag([
    1 => [
        ['id' => 1, 'name' => 'Name 1'],
        ['id' => 2, 'name' => 'Name 2']
    ],
    3 => [
        ['id' => 3, 'name' => 'Name 3']
    ]
]);
$bag->all(); //array(2 items, 1 item)
$bag->withKey(1); //array(2 items)
$bag->withKey(5); //array(0 items)
$bag->collect('name'); //['Name 1', 'Name 2', 'Name 3']
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

5

Last Release

893d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/792682?v=4)[Marian Kostadinov](/maintainers/kapitancho)[@kapitancho](https://github.com/kapitancho)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/walnut-lib-dbquery/health.svg)

```
[![Health](https://phpackages.com/badges/walnut-lib-dbquery/health.svg)](https://phpackages.com/packages/walnut-lib-dbquery)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/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)
