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

Maintainers

👁 adrianmiu

Package info

github.com/siriusphp/sql

pkg:composer/siriusphp/sql

Statistics

Installs: 489

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

1.2.1 2020-11-24 15:03 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT f8ee05694f86578f9b2d0654d4b90b8e80fe134a

  • Adrian Miu <adrian.woop@adrianmiu.ro>

This package is auto-updated.

Last update: 2026-06-25 02:57:00 UTC


README

👁 Source Code
👁 Latest Version
👁 Software License
👁 Build Status
👁 Coverage Status
👁 Quality Score

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

Acknowledgements

This library is a derivative work of atlas/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 . '%')