PHPackages                             lucinda/queries - 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. lucinda/queries

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

lucinda/queries
===============

API that generates SQL statements programmatically based on official standards or their vendor-specific derivation

v4.0.2(3w ago)122.9k—0%2MITPHPPHP ^8.1

Since Dec 11Pushed 3w ago1 watchersCompare

[ Source](https://github.com/aherne/php-sql-statements-api)[ Packagist](https://packagist.org/packages/lucinda/queries)[ Docs](https://github.com/aherne/php-sql-statements-api)[ RSS](/packages/lucinda-queries/feed)WikiDiscussions master Synced today

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

SQL Statements API
==================

[](#sql-statements-api)

Table of contents:

- [About](#about)
- [Installation](#installation)
- [Unit Tests](#unit-tests)
- [Examples](#examples)
- [Reference Guide](#reference-guide)

About
-----

[](#about)

The purpose of this API is to automate generation of SQL statements (queries) based on SQL standards or their vendor-specific derivation. API is fully PSR-4 compliant, only requiring PHP7.1+ interpreter. To quickly see how it works, check:

- **[installation](#installation)**: describes how to install API on your computer
- **[unit tests](#unit-tests)**: API has 100% Unit Test coverage, using [UnitTest API](https://github.com/aherne/unit-testing) instead of PHPUnit for greater flexibility
- **[examples](#examples)**: shows a example of API functionality

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

[](#installation)

To install this api, you only need to go to your project root then run this command from console:

```
composer require lucinda/queries
```

Once you have it installed, you're able to generate queries. Each standard SQL statement corresponds to one or more classes:

- **SELECT**:
    - [Lucinda\\Query\\Select](#class-select): encapsulates a single SELECT statement (eg: SELECT id FROM table)
    - [Lucinda\\Query\\SelectGroup](#class-selectgroup): encapsulates a group of SELECT statements united by a SET operator (eg: (SELECT id from table1) UNION (SELECT id FROM table2))
- **INSERT**:
    - [Lucinda\\Query\\Insert](#class-insert): encapsulates an INSERT INTO ... VALUES statement (eg: INSERT INTO table (id, name) VALUES (1, 'asd'))
    - [Lucinda\\Query\\InsertSelect](#class-insertselect): encapsulates an INSERT INTO ... SELECT statement (eg: INSERT INTO table (id, name) SELECT id, name FROM table2)
- **UPDATE**:
    - [Lucinda\\Query\\Update](#class-update): encapsulates an UPDATE statement (eg: UPDATE users SET name='Lucian' WHERE id=18)
- **DELETE**:
    - [Lucinda\\Query\\Delete](#class-delete): encapsulates a DELETE statement (eg: DELETE FROM users WHERE id=18)
- **TRUNCATE**:
    - [Lucinda\\Query\\Truncate](#class-truncate): encapsulates a TRUNCATE statement (eg: TRUNCATE TABLE users)

For each vendor implementing SQL standards, you can either use above or their vendor-specific derivations. MySQL vendor is already supported:

- **SELECT**:
    - [Lucinda\\Query\\Vendor\\MySQL\\Select](#class-mysql-select): extends [Lucinda\\Query\\Select](#class-select) in order to support vendor-specific operations (eg: SQL\_NO\_CACHE)
- **INSERT**:
    - [Lucinda\\Query\\Vendor\\MySQL\\Insert](#class-mysql-insert): extends [Lucinda\\Query\\Insert](#class-insert) in order to support vendor-specific operations (eg: IGNORE)
    - [Lucinda\\Query\\Vendor\\MySQL\\InsertSelect](#class-mysql-insertselect): extends [Lucinda\\Query\\InsertSelect](#class-insertselect) in order to support vendor-specific operations (eg: IGNORE)
    - [Lucinda\\Query\\Vendor\\MySQL\\InsertSet](#class-mysql-insertset): encapsulates vendor-specific statement INSERT INTO ... SET statement (eg: INSERT INTO table (id, name) SET id=1, name='Lucian')
- **REPLACE**:
    - [Lucinda\\Query\\Vendor\\MySQL\\Replace](#class-mysql-replace): extends [Lucinda\\Query\\Insert](#class-insert) in order to support vendor-specific REPLACE INTO ... VALUES statement
    - [Lucinda\\Query\\Vendor\\MySQL\\ReplaceSelect](#class-mysql-replaceselect): extends [Lucinda\\Query\\InsertSelect](#class-insertselect) in order to support vendor-specific REPLACE INTO ... SELECT statement
    - [Lucinda\\Query\\Vendor\\MySQL\\ReplaceSet](#class-mysql-replaceset): encapsulates vendor-specific statement REPLACE INTO ... SET statement (eg: REPLACE INTO table (id, name) SET id=1, name='Lucian')
- **UPDATE**
    - [Lucinda\\Query\\Vendor\\MySQL\\Update](#class-mysql-update): extends [Lucinda\\Query\\Update](#class-update) in order to support vendor-specific operations (eg: IGNORE)
- **DELETE**
    - [Lucinda\\Query\\Vendor\\MySQL\\Delete](#class-mysql-delete): extends [Lucinda\\Query\\Delete](#class-delete) in order to support vendor-specific operations (eg: IGNORE)

Each of above, or clauses they individually call, implement **\\Stringable** that converts them to a raw SQL statement.

Unit Tests
----------

[](#unit-tests)

For tests and examples, check following files/folders in API sources:

- [test.php](https://github.com/aherne/php-sql-statements-api/blob/master/test.php): runs unit tests in console
- [unit-tests.xml](https://github.com/aherne/php-sql-statements-api/blob/master/unit-tests.xml): sets up unit tests
- [tests](https://github.com/aherne/php-sql-statements-api/tree/master.0/tests): unit tests for classes from [src](https://github.com/aherne/php-sql-statements-api/tree/master.0/src) folder
- [tests\_drivers](https://github.com/aherne/php-sql-statements-api/tree/master.0/tests_drivers): unit tests for classes from [drivers](https://github.com/aherne/php-sql-statements-api/tree/master.0/drivers) folder

Examples
--------

[](#examples)

To see examples how each classes are used, check unit tests in **[tests](https://github.com/aherne/php-sql-statements-api/tree/master.0/tests)** or **[tests\_drivers](https://github.com/aherne/php-sql-statements-api/tree/master.0/tests_frivers)** folder! Simple example:

```
$statement = new \Lucinda\Query\Select("users", "t1");
$statement->fields(["t3.name"]);
$statement->joinInner("user_departments", "t2")->on(["t1.id"=>"t2.user_id"]);
$statement->joinInner("departments", "t3")->on(["t2.department_id"=>"t3.id"]);
$statement->where(["t1.id"=>":id"]);
$statement->orderBy(["t3.name"]);
```

Encapsulating:

```
SELECT t3.name
FROM users AS t1
INNER JOIN user_departments AS t2 ON t1.id = t2.user_id
INNER JOIN departments AS t3 ON t2.department_id = t3.id
WHERE t1.id = :id
ORDER BY t3.name
```

Reference Guide
---------------

[](#reference-guide)

### Class Select

[](#class-select)

[Lucinda\\Query\\Select](https://github.com/aherne/php-sql-statements-api/blob/master/src/Select.php) encapsulates a standard SELECT statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring|Select|SelectGroup $tableDefinition string $alias=""voidConstructs a SELECT statement based on table name and optional aliasdistinctvoidvoidSets statement as DISTINCT, filtering out repeating rowsfieldsarray $columns = \[\][Lucinda\\Query\\Clause\\Fields](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Fields.php)Sets fields or columns to selectjoinLeftstring|Select|SelectGroup $tableDefinition, string $tableAlias = ""[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a LEFT JOIN statementjoinRightstring|Select|SelectGroup $tableDefinition, string $tableAlias = ""[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a RIGHT JOIN statementjoinInnerstring|Select|SelectGroup $tableDefinition, string $tableAlias = ""[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a INNER JOIN statementjoinCrossstring|Select|SelectGroup $tableDefinition, string $tableAlias = ""[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a CROSS JOIN statementwherearray $condition=\[\], string $logicalOperator = [Lucinda\\Query\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/src/Operator/Logical.php)::*AND*[Lucinda\\Query\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Condition.php)Sets up WHERE clause.groupByarray $columns = \[\], bool $withRollup = false[Lucinda\\Query\\Clause\\Columns](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Columns.php)Sets up GROUP BY statementhavingarray $condition=\[\], string $logicalOperator = [Lucinda\\Query\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/src/Operator/Logical.php)::*AND*[Lucinda\\Query\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Condition.php)Sets up HAVING clause.orderByarray $fields = \[\][Lucinda\\Query\\Clause\\OrderBy](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/OrderBy.php)Sets up ORDER BY clauselimitint $limit, int $offset=0voidSets a LIMIT clausewithbool $isRecursive = false[Lucinda\\Query\\Clause\\With](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/With.php)Sets a WITH statementwindowvoid[Lucinda\\Query\\Clause\\Window](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Window.php)Sets a WINDOW function statement### Class SelectGroup

[](#class-selectgroup)

[Lucinda\\Query\\SelectGroup](https://github.com/aherne/php-sql-statements-api/blob/master/src/SelectGroup.php) encapsulates a list of SELECT statements joined by a SET operator (eg: UNION) via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $operator = [Lucinda\\Query\\Operator\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Operator/Set.php)::UNIONvoidConstructs a SELECT ... OPERATOR ... SELECT statement based on Set OPERATORaddSelect[Lucinda\\Query\\Select](https://github.com/aherne/php-sql-statements-api/blob/master/src/Select.php) $selectvoidAdds SELECT statement to groupaddSelect[Lucinda\\Query\\SelectGroup](https://github.com/aherne/php-sql-statements-api/blob/master/src/SelectGroup.php) $selectvoidAdds SELECT ... OPERATOR ... SELECT statement to grouporderByarray $fields = \[\][Lucinda\\Query\\Clause\\OrderBy](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/OrderBy.php)Sets up ORDER BY clauselimitint $limit, int $offset=0voidSets a LIMIT clause### Class Insert

[](#class-insert)

[Lucinda\\Query\\Insert](https://github.com/aherne/php-sql-statements-api/blob/master/src/Insert.php) encapsulates a standard INSERT INTO VALUES statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a INSERT INTO ... VALUES statement based on table namecolumnsarray $columns = \[\][Lucinda\\Query\\Clause\\Columns](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Columns.php)Sets columns that will be inserted into.valuesarray $updates = \[\][Lucinda\\Query\\Clause\\Row](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Row.php)Adds row to table via list of values to insert in columns### Class InsertSelect

[](#class-insertselect)

[Lucinda\\Query\\InsertSelect](https://github.com/aherne/php-sql-statements-api/blob/master/src/InsertSelect.php) encapsulates a standard INSERT INTO SELECT statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a INSERT INTO ... SELECT statement based on table namewithbool $isRecursive = false[Lucinda\\Query\\Clause\\With](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/With.php)Sets a WITH statementcolumnsarray $columns = \[\][Lucinda\\Query\\Clause\\Columns](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Columns.php)Sets columns that will be inserted into.select[Lucinda\\Query\\Select](https://github.com/aherne/php-sql-statements-api/blob/master/src/Select.php) $selectvoidSets rows to insert based on a SELECT statementselect[Lucinda\\Query\\SelectGroup](https://github.com/aherne/php-sql-statements-api/blob/master/src/SelectGroup.php) $selectvoidSets rows to insert based on a SELECT ... OPERATOR ... SELECT group statement### Class Update

[](#class-update)

[Lucinda\\Query\\Update](https://github.com/aherne/php-sql-statements-api/blob/master/src/Update.php) encapsulates a standard UPDATE statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a UPDATE statement based on table namewithbool $isRecursive = false[Lucinda\\Query\\Clause\\With](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/With.php)Sets a WITH statementsetarray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up SET clause.wherearray $condition = \[\], string $logicalOperator = [Lucinda\\Query\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/src/Operator/Logical.php)::*AND*[Lucinda\\Query\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Condition.php)Sets up WHERE clause.### Class Delete

[](#class-delete)

[Lucinda\\Query\\Delete](https://github.com/aherne/php-sql-statements-api/blob/master/src/Delete.php) encapsulates a standard DELETE statement via following public methods:

MethodArgumentsReturnsDescriptionwithbool $isRecursive = false[Lucinda\\Query\\Clause\\With](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/With.php)Sets a WITH statement\_\_constructstring $tablevoidConstructs a DELETE statement based on table namewherearray $condition=\[\], string $logicalOperator = [Lucinda\\Query\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/src/Operator/Logical.php)::*AND*[Lucinda\\Query\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Condition.php)Sets up WHERE clause.### Class Truncate

[](#class-truncate)

[Lucinda\\Query\\Truncate](https://github.com/aherne/php-sql-statements-api/blob/master/src/Truncate.php) encapsulates a standard TRUNCATE statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a TRUNCATE statement based on table name### Class MySQL Select

[](#class-mysql-select)

[Lucinda\\Query\\Vendor\\MySQL\\Select](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Select.php) encapsulates a MySQL SELECT statement on top of [Lucinda\\Query\\Select](https://github.com/aherne/php-sql-statements-api/blob/master/src/Select.php) via following extra methods:

MethodArgumentsReturnsDescriptionsetCalcFoundRowsvoidvoidAppends a SQL\_CALC\_FOUND\_ROWS option to SELECTsetStraightJoinvoidvoidAppends a STRAIGHT\_JOIN option to SELECTgetCalcFoundRowsvoidstringGets query to retrieve found rows after a SELECT with SQL\_CALC\_FOUND\_ROWS has ranIn addition of above operations, *where* method can use:

- [Lucinda\\Query\\Vendor\\MySQL\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Clause/Condition.php) to support regexp condition and fulltext searches
- [Lucinda\\Query\\Vendor\\MySQL\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Operator/Logical.php) to support XOR operator

### Class MySQL Insert

[](#class-mysql-insert)

[Lucinda\\Query\\Vendor\\MySQL\\Insert](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Insert.php) encapsulates a MySQL INSERT INTO VALUES statement on top of [Lucinda\\Query\\Insert](https://github.com/aherne/php-sql-statements-api/blob/master/src/Insert.php) via following extra methods:

MethodArgumentsReturnsDescriptionignorevoidvoidSets statement as IGNORE, ignoring foreign key errors and duplicatesonDuplicateKeyUpdatearray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up ON DUPLICATE KEY UPDATE clause.### Class MySQL InsertSelect

[](#class-mysql-insertselect)

[Lucinda\\Query\\Vendor\\MySQL\\InsertSelect](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/InsertSelect.php) encapsulates a MySQL INSERT INTO SELECT statement on top of [Lucinda\\Query\\InsertSelect](https://github.com/aherne/php-sql-statements-api/blob/master/src/InsertSelect.php) via following extra methods:

MethodArgumentsReturnsDescriptionignorevoidvoidSets statement as IGNORE, ignoring foreign key errors and duplicatesonDuplicateKeyUpdatearray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up ON DUPLICATE KEY UPDATE clause.### Class MySQL InsertSet

[](#class-mysql-insertset)

[Lucinda\\Query\\Vendor\\MySQL\\InsertSet](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/InsertSet.php) encapsulates a MySQL INSERT INTO SET statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a INSERT INTO ... SET statement based on table nameignorevoidvoidSets statement as IGNORE, ignoring foreign key errors and duplicatessetarray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up SET clause.onDuplicateKeyUpdatearray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up ON DUPLICATE KEY UPDATE clause.### Class MySQL Replace

[](#class-mysql-replace)

[Lucinda\\Query\\Vendor\\MySQL\\Replace](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Replace.php) encapsulates a MySQL REPLACE INTO VALUES statement on top of [Lucinda\\Query\\Insert](https://github.com/aherne/php-sql-statements-api/blob/master/src/Insert.php) with no extra methods, except that INSERT will have REPLACE instead.

### Class MySQL ReplaceSelect

[](#class-mysql-replaceselect)

[Lucinda\\Query\\Vendor\\MySQL\\ReplaceSelect](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/ReplaceSelect.php) encapsulates a MySQL REPLACE INTO SELECT statement on top of [Lucinda\\Query\\InsertSelect](https://github.com/aherne/php-sql-statements-api/blob/master/src/InsertSelect.php) with no extra methods, except that INSERT will have REPLACE instead.

### Class MySQL ReplaceSet

[](#class-mysql-replaceset)

[Lucinda\\Query\\Vendor\\MySQL\\ReplaceSet](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/ReplaceSet.php) encapsulates a MySQL REPLACE INTO SET statement via following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $tablevoidConstructs a REPLACE INTO ... SET statement based on table namesetarray $contents = \[\][Lucinda\\Query\\Clause\\Set](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Set.php)Sets up SET clause.### Class MySQL Update

[](#class-mysql-update)

[Lucinda\\Query\\Vendor\\MySQL\\Update](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Update.php) encapsulates a MySQL UPDATE statement on top of [Lucinda\\Query\\Update](https://github.com/aherne/php-sql-statements-api/blob/master/src/Update.php) via following extra methods:

MethodArgumentsReturnsDescriptionignorevoidvoidSets statement as IGNORE, ignoring foreign key errors and duplicatesjoinLeftstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a LEFT JOIN statementjoinRightstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a RIGHT JOIN statementjoinInnerstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a INNER JOIN statementjoinCrossstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a CROSS JOIN statementIn addition of above operations, *where* method can use:

- [Lucinda\\Query\\Vendor\\MySQL\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Clause/Condition.php) to support regexp condition and fulltext searches
- [Lucinda\\Query\\Vendor\\MySQL\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Operator/Logical.php) to support XOR operator

### Class MySQL Delete

[](#class-mysql-delete)

[Lucinda\\Query\\Vendor\\MySQL\\Delete](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Delete.php) encapsulates a MySQL DELETE statement on top of [Lucinda\\Query\\Delete](https://github.com/aherne/php-sql-statements-api/blob/master/src/Delete.php) via following extra methods:

MethodArgumentsReturnsDescriptionignorevoidvoidSets statement as IGNORE, ignoring foreign key errors and duplicatesjoinLeftstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a LEFT JOIN statementjoinRightstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a RIGHT JOIN statementjoinInnerstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a INNER JOIN statementjoinCrossstring $tableName[Lucinda\\Query\\Clause\\Join](https://github.com/aherne/php-sql-statements-api/blob/master/src/Clause/Join.php)Adds a CROSS JOIN statementIn addition of above operations, *where* method can use:

- [Lucinda\\Query\\Vendor\\MySQL\\Clause\\Condition](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Clause/Condition.php) to support regexp condition and fulltext searches
- [Lucinda\\Query\\Vendor\\MySQL\\Operator\\Logical](https://github.com/aherne/php-sql-statements-api/blob/master/drivers/MySQL/Operator/Logical.php) to support XOR operator

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.2% 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 ~85 days

Recently: every ~67 days

Total

33

Last Release

21d ago

Major Versions

v1.0.x-dev → v2.0.42021-02-25

v2.0.5 → v3.0.02021-12-31

v2.0.6 → v3.0.12022-01-09

v2.1.2 → v3.1.02025-09-16

v2.0.x-dev → v4.0.12026-06-13

PHP version history (3 changes)v2.0.0PHP ^7.1

v3.0.0PHP ^8.1

v2.0.6PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3382770?v=4)[Lucian Gabriel Popescu](/maintainers/aherne)[@aherne](https://github.com/aherne)

---

Top Contributors

[![aherne](https://avatars.githubusercontent.com/u/3382770?v=4)](https://github.com/aherne "aherne (35 commits)")[![luciangreentree](https://avatars.githubusercontent.com/u/20677068?v=4)](https://github.com/luciangreentree "luciangreentree (1 commits)")

---

Tags

sqlquerygeneration

### Embed Badge

![Health badge](/badges/lucinda-queries/health.svg)

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

###  Alternatives

[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.4M14](/packages/rennokki-laravel-eloquent-query-cache)[aura/sqlquery

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

4883.1M39](/packages/aura-sqlquery)[nilportugues/sql-query-builder

An elegant lightweight and efficient SQL QueryInterface BuilderInterface supporting bindings and complicated query generation.

428244.5k6](/packages/nilportugues-sql-query-builder)[supliu/laravel-query-monitor

Laravel Query Monitor

285114.6k](/packages/supliu-laravel-query-monitor)[illuminated/db-profiler

Database Profiler for Laravel Web and Console Applications.

169242.3k](/packages/illuminated-db-profiler)[nilportugues/sql-query-formatter

A very lightweight PHP class that reformats unreadable and computer-generated SQL query statements to human-friendly, readable text.

391.2M29](/packages/nilportugues-sql-query-formatter)

PHPackages © 2026

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