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

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

wtframework/sql
===============

What the Framework?! SQL

v0.3.1(1y ago)104471MITPHPPHP ^8.2

Since Jan 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wtframework/sql)[ Packagist](https://packagist.org/packages/wtframework/sql)[ RSS](/packages/wtframework-sql/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (14)Used By (1)

What the Framework?! SQL
========================

[](#what-the-framework-sql)

This library provides a fluent interface for generating SQL statement strings.

The [DBAL](https://github.com/wtframework/dbal) library extends this library with a wrapper for PDO.

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

[](#installation)

```
composer require wtframework/sql
```

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

[](#documentation)

### Supported grammars

[](#supported-grammars)

- MariaDB
- MySQL
- PostgreSQL
- SQLite
- TSQL

### Supported statements

[](#supported-statements)

- [DELETE](docs/delete.md)
- [INSERT](docs/insert.md)
- [REPLACE](docs/replace.md)
- [SELECT](docs/select.md)
- [TRUNCATE](docs/truncate.md)
- [UPDATE](docs/update.md)
- [ALTER TABLE](docs/alter.md)
- [CREATE TABLE](docs/create.md)
- [CREATE INDEX](docs/create-index.md)
- [DROP TABLE](docs/drop.md)
- [DROP INDEX](docs/drop-index.md)

### Example

[](#example)

```
use WTFramework\SQL\SQL;

echo $stmt = SQL::select()
->from('users')
->where('email_address', 'admin@example.net');
```

```
SELECT * FROM users WHERE email_address = ?

```

After casting the object to a string, like above, the `bindings` method will return an array of bound parameters.

```
print_r($stmt->bindings());
```

```
Array
(
    [0] => admin@example.net
)

```

### Grammars

[](#grammars)

The default global grammar is `MySQL`. Use the static `SQL::use` method to change this. This will not apply to any existing statements.

```
use WTFramework\SQL\Grammar;

$stmt1 = SQL::select();

SQL::use(Grammar::TSQL);

$stmt2 = SQL::select();

// $stmt1 will use MySQL, $stmt2 will use TSQL.
```

The `use` method can also be used to override the grammar of an individual statement.

```
$stmt1->use(Grammar::PostgreSQL);
```

Extending the library
---------------------

[](#extending-the-library)

To extend the library you can use the static `macro` method, passing the new method name and a closure to call. This works for both static and non-static methods. This is available on the `SQL` class as well as all statement and service classes.

```
use WTFramework\SQL\SQL;

SQL::macro('count', function (string $table)
{

  return static::select()
  ->column('COUNT(*) AS counter')
  ->from($table);

});
```

```
SQL::count('users');
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Every ~20 days

Recently: every ~1 days

Total

13

Last Release

609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/593fc3635659d661daf87a3debf99abd502bc0f7e4cce916319d37143775c8da?d=identicon)[wtframework](/maintainers/wtframework)

---

Top Contributors

[![MichaelRushton](https://avatars.githubusercontent.com/u/49325097?v=4)](https://github.com/MichaelRushton "MichaelRushton (28 commits)")

###  Code Quality

TestsPest

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/wtframework-sql/health.svg)](https://phpackages.com/packages/wtframework-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)
