PHPackages                             siriusphp/sql - 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. siriusphp/sql

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

siriusphp/sql
=============

Flexible query building library for PDO connections with a small API surface and auto-complete support (low cognitive load). Requires an atlas/pdo connection.

1.2.1(5y ago)14891MITPHPPHP &gt;=7.1CI failing

Since Feb 8Pushed 5y ago1 watchersCompare

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

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

Sirius Sql
==========

[](#sirius-sql)

[![Source Code](https://camo.githubusercontent.com/1cd0c61ca66ebbe6bdd174ff8aa5b6f3b6575495430fd07c7f971cbf5c798f41/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d7369726975737068702f73716c2d626c75652e737667)](https://github.com/siriusphp/sql)[![Latest Version](https://camo.githubusercontent.com/25849e9de24f06322f938270a7c53b685ac4f0b7395701c61037947647271a63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369726975737068702f73716c2e737667)](https://github.com/siriusphp/sql/releases)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/siriusphp/sql/blob/master/LICENSE)[![Build Status](https://github.com/siriusphp/sql/workflows/CI/badge.svg)](https://github.com/siriusphp/sql/actions)[![Coverage Status](https://camo.githubusercontent.com/ae7a6d8455bd4a3e87e1ad8b069dd98a76e6ec84b493fb9fe0f2e506535a4c6c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7369726975737068702f73716c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/siriusphp/sql/code-structure)[![Quality Score](https://camo.githubusercontent.com/549a50d1acb12e6c6882209a66fee35120687cc6ca8c5ad543f424969aff9a2f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7369726975737068702f73716c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/siriusphp/sql)

The `siriusphp/sql` library is designed to help you build and execute SQL simple and complex queries in a fast and safe way.

The vocabulary is as close to SQL as possible as you may see from the example below:

```
use Atlas\Pdo\Connection;
use Sirius\Sql\Select;
use Sirius\Sql\ConditionsEnum;

$connection = Connection::new('sqlite::memory:');
$select = new Select($connection);

// find the 10 "cool" posts that are published and also retrieve the comments count
$select->distinct()
    ->columns('posts.*', 'COUNT(comments.id) AS comments_count')
    ->from('posts')
    ->join('LEFT', 'comments', 'comments.commentable_id = posts.id AND comments.commentable_type = %s', 'posts')
    ->where('posts.published_at < NOW()')
    ->where('posts.title', 'cool', ConditionsEnum::CONTAINS)
    ->groupBy('posts.id')
    ->limit(10);

$posts = $select->fectchAll();
```

Links
-----

[](#links)

- [documentation](http://sirius.ro/php/sirius/sql/)
- [changelog](CHANGELOG.md)

Acknowledgements
----------------

[](#acknowledgements)

This library is a derivative work of [atlas/query](http://atlasphp.io/cassini/query/). I made this library for 2 reasons:

- to reduce cognitive load by removing some methods and implementing other ways to achieve the same goals (eg: nested conditions)
- to optimize some operations for the most common scenarios (eg: `where($column, $str, 'does_not_contain')` vs `where($column . ' LIKE ', '%' . $str . '%')`

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Total

4

Last Release

2001d ago

### Community

Maintainers

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

---

Tags

mysqlpdopdo-phpphpquerysqlsqlite

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/siriusphp-sql/health.svg)

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

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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