PHPackages                             arekx/pql - 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. arekx/pql

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

arekx/pql
=========

PHP Query Builder

1.0.0(1y ago)22[1 PRs](https://github.com/ArekX/PQL/pulls)MITPHPPHP &gt;=8.2CI passing

Since Sep 12Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ArekX/PQL)[ Packagist](https://packagist.org/packages/arekx/pql)[ RSS](/packages/arekx-pql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

PQL
===

[](#pql)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/99be7ac7618842a62b95d7de6f22bb4ce5fde9034a7367b5c64e943ed01729c1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4172656b582f50514c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ArekX/PQL/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/aafc825e861afa9070ee7aa23f230b62d40d759a25373ea2d301eb00889cbbb2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4172656b582f50514c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ArekX/PQL/?branch=master)[![Build Status](https://camo.githubusercontent.com/cad64919e6db3598dfe9ff7fce5ed930c2d9612b1338b4b393e8ffaeb19aee35/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4172656b582f50514c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ArekX/PQL/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/5d387ad89d3d53028466d7c5f9aadf6f09ea8d05d33292571a9e2885c509fb0e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4172656b582f50514c2f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Documentation Status](https://camo.githubusercontent.com/b6842903717e4d9fcb21d2cc2a966f8c587d3837c1fa82de4d2adb505f64979c/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f70716c2f62616467652f3f76657273696f6e3d6c6174657374)](https://pql.readthedocs.io/en/latest/?badge=latest)

PHP Database Query Library

This library is a database abstraction layer which abstracts the query commands (Select, Delete, Update, etc.) out from the drivers (MySQL, Postgres, SQL Server, etc.). Queries are defined in an eloquent way allowing you to write almost all kinds of queries without having to rely on passing raw query data.

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

[](#installation)

Installing this library is done via composer `composer install arekxv/pql` (still WIP)

Usage
-----

[](#usage)

First you need to decide on which driver you will use. Following drivers are supported:

- [MySQL](docs/drivers/mysql.md)

After you decide on the driver, writing a query is as simple as:

```
use function \ArekX\PQL\Sql\{select, all, equal, column, value};

// ... driver and builder initialization left out for brevity.

/** @var \ArekX\PQL\Contracts\Driver $driver */
/** @var \ArekX\PQL\Contracts\QueryBuilder $builder */

$runner = QueryRunner::create($driver, $builder);

// Fetching all results

$query = select('*') // or Select::create()->columns('*') if you do not want to use functions.
    ->from('user')
    ->where(all(['is_active' => 1]));

// Built query equals to: SELECT * FROM `user` WHERE `is_active` = 1;
$runner->fetchAll($query); // Returns all data for user table

// Complex select query:
$query = select('*')
    ->from(['u' => 'user'])
    ->innerJoin(['r' => 'user_role'], 'u.role_id = r.id')
    ->where(['all', [
         'u.is_active' => 1,
         'r.id' => select('role_id')
                    ->from('application_roles')
                    ->where(equal(column('application_id'), value(2)))
      ]);
/*
Built query equals to:
SELECT
    *
FROM `user` AS `u`
INNER JOIN `user_role` AS `r` ON u.role_id = r.id
WHERE
 `u`.`is_active` = 1
 AND `r`.`id` IN (
    SELECT `role_id` FROM `application_roles` WHERE `application_id` = 2
 )
*/
$runner->fetchAll($query); // Returns all data for this query
```

Documentation
-------------

[](#documentation)

Documentation is available in [here](docs/index.md) (in docs folder).

HTML version of the docs is available at:

Testing
-------

[](#testing)

Run `composer install` and then run `composer test`. This will run unit and integration tests.

For integration tests, database docker containers must be running otherwise those tests will fail.

To setup docker containers install docker and inside `tests` folder run `docker-compose up -d`.

To just run unit tests run `composer test-unit`.

For coverage report run `composer coverage` or you can take a look at it [here](https://scrutinizer-ci.com/g/ArekX/PQL/?branch=master).

License
-------

[](#license)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an " AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance60

Regular maintenance activity

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 99.1% 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

624d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c16806a6fc4805b54005c72ea7aa0b6bc33f889a4a657a3071953f6b4e4a23c?d=identicon)[ArekXV](/maintainers/ArekXV)

---

Top Contributors

[![ArekX](https://avatars.githubusercontent.com/u/4344776?v=4)](https://github.com/ArekX "ArekX (109 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

agnosticdatabasedrivermysqlphpsql

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/arekx-pql/health.svg)

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

###  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)
