PHPackages                             flatphp/query - 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. flatphp/query

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

flatphp/query
=============

db query component

v1.0.0(5y ago)02MITPHP

Since Sep 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/flatphp/query)[ Packagist](https://packagist.org/packages/flatphp/query)[ RSS](/packages/flatphp-query/feed)WikiDiscussions master Synced 1w ago

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

query
=====

[](#query)

light ORM based by [flatphp/lightdb](https://github.com/flatphp/lightdb)

usage
=====

[](#usage)

```
use \Flatphp\Query\QueryResolver;
use \Flatphp\Query\Model;
use \Flatphp\Query\DbQuery;
use \Lightdb\DB;

$conf = array(
	'dsn' => 'mysql:host=localhost;dbname=sc_web',
	'username' => 'name',
	'password' => '123456',
	'options' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'],
);
DB::init($conf);

/**
 * @property string $ch_code
 * @property string $ch_name
 */
class ChannelModel extends Model
{
}

/**
 * @method static ChannelQuery channel()
 */
class ChannelQuery extends DbQuery
{
	protected $table = 'cat_channel';
	protected $model = 'ChannelModel';

    public function whereChCode($value)
    {
        $this->query->where('ch_code=?', $value);
        return $this;
    }
}

/**
 * @method static ChannelQuery channel()
 */
class Query extends QueryResolver
{
    protected static $namespace = __NAMESPACE__;
}

$channel = Query::channel()->whereChCode('test')->getOne();
$channels = Query::channel()->getAll();
Query::channel()->insert($channel);
Query::channel()->update($channel);
Query::channel()->whereChCode('hello')->delete();

// debug mode
$sql = Query::channel()->whereChCode('test')->preview()->getOne();
print_r($sql);

$sql = Query::channel()->whereChCode('test')->preview()->update($channel);
print_r($sql);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2084d ago

### Community

Maintainers

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

---

Top Contributors

[![shukyoo](https://avatars.githubusercontent.com/u/2231396?v=4)](https://github.com/shukyoo "shukyoo (2 commits)")

---

Tags

databasequery

### Embed Badge

![Health badge](/badges/flatphp-query/health.svg)

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

###  Alternatives

[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)[lichtner/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921274.8k6](/packages/lichtner-fluentpdo)[bvanhoekelen/performance

PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.

521774.3k4](/packages/bvanhoekelen-performance)[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921244.9k7](/packages/fpdo-fluentpdo)[tpetry/laravel-query-expressions

Database-independent Query Expressions as a replacement to DB::raw calls

357436.5k2](/packages/tpetry-laravel-query-expressions)

PHPackages © 2026

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