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

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

solution10/sql
==============

Completely standalone, expressive SQL query creator. No database or ORM needed.

v1.3.0(10y ago)8122.5k↓30.8%2[2 issues](https://github.com/Solution10/sql/issues)1MITPHPPHP &gt;= 5.4

Since Jul 1Pushed 10y ago2 watchersCompare

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

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

Solution10\\SQL
===============

[](#solution10sql)

Completely standalone, expressive SQL query creator. No database or ORM needed.

[![Build Status](https://camo.githubusercontent.com/9c6d6db6239d4b0ed5731ab737676938755d571792c864974ba1b4de2f6e63ea/68747470733a2f2f7472617669732d63692e6f72672f536f6c7574696f6e31302f73716c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Solution10/sql)[![Coverage Status](https://camo.githubusercontent.com/2bd3ced8ce052803f0ca1674ba5a9c5f4aa771b4ff4d0b105e39ab719b8fb78e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f536f6c7574696f6e31302f73716c2f62616467652e706e67)](https://coveralls.io/r/Solution10/sql)

[![Latest Stable Version](https://camo.githubusercontent.com/01143715a24d3426c4a996b2f93b7a0164746dae6a0a9d1f738b832d4cb54cd1/68747470733a2f2f706f7365722e707567782e6f72672f736f6c7574696f6e31302f73716c2f762f737461626c652e737667)](https://packagist.org/packages/solution10/sql)[![Total Downloads](https://camo.githubusercontent.com/d0cd04c46e7b0e9203b917f382a542d1809aab8764a4826b3a6d3d254009bfdf/68747470733a2f2f706f7365722e707567782e6f72672f736f6c7574696f6e31302f73716c2f646f776e6c6f6164732e737667)](https://packagist.org/packages/solution10/sql)[![License](https://camo.githubusercontent.com/aef333f390ec83822b2568cf72251e0936d72c1472dd27dc5951a428fa91bf9c/68747470733a2f2f706f7365722e707567782e6f72672f736f6c7574696f6e31302f73716c2f6c6963656e73652e737667)](https://packagist.org/packages/solution10/sql)

Features
--------

[](#features)

- No database connection required, entirely standalone
- Return SQL string and params in order for PDO queries
- Support for MySQL and ANSI SQL variations
- Complex queries (nested where, having etc)
- Simple, expressive syntax
- Can return query parts at any point

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

[](#installation)

Installation is via composer, in the usual manner:

```
{
    "require": {
        "solution10/sql": "~1.0"
    }
}
```

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

[](#documentation)

### Simple Examples

[](#simple-examples)

For more detailed documentation, please check the /docs folder in the repo, or the Wiki.

#### Select

[](#select)

```
$query = (new Solution10\SQL\Select())
    ->select(['users.name', 'locations.name'])
    ->from('users')
    ->join('locations', 'users.location_id', '=', 'locations.id')
    ->where('users.id', '>', 15)
    ->limit(25)
    ->offset(10)
    ->orderBy('name', 'DESC');

// Make use of an existing PDO object to actually run the query:
$stmt = $pdo->prepare((string)$query);
$stmt->execute($query->params());
$rows = $stmt->fetchAll();
```

#### Insert

[](#insert)

```
$query = (new Solution10\SQL\Insert())
    ->table('users')
    ->values([
        'name' => 'Alex',
        'location_id' => 27
    ]);

// Use with PDO in exactly the same way as SELECT:
$stmt = $pdo->prepare((string)$query);
$stmt->execute($query->params());
```

#### Update

[](#update)

```
$query = (new Solution10\SQL\Update())
    ->table('users')
    ->where('id', '=', 15)
    ->values([
        'name' => 'Alex',
        'location_id' => 27
    ]);

// Use with PDO in exactly the same way as SELECT:
$stmt = $pdo->prepare((string)$query);
$stmt->execute($query->params());
```

#### Delete

[](#delete)

```
$query = (new Solution10\SQL\Delete())
    ->table('users')
    ->where('id', '=', 27)
    ->limit(1);

// Use with PDO in exactly the same way as SELECT:
$stmt = $pdo->prepare((string)$query);
$stmt->execute($query->params());
```

#### Using other dialects

[](#using-other-dialects)

By default, S10\\SQL will assume that you're using an ANSI SQL compatible database. If you're using something else, MySQL for instance, simply pass into the constructor the Dialect instance:

```
$query = (new Solution10\SQL\Select(new Solution10\SQL\Dialect\MySQL()))
    ->select('*')
    ->from('users')
    ->limit(10);
```

You can also write your own dialects by implementing `Solution10\SQL\DialectInterface`.

### Userguide

[](#userguide)

[Check out the Wiki](https://github.com/Solution10/sql/wiki)

(or the /docs folder in the repo)

### API Docs

[](#api-docs)

From a checkout of this project, run:

```
$ make

```

This will create an api/ folder for you to peruse.

PHP Requirements
----------------

[](#php-requirements)

- PHP &gt;= 5.4

Author
------

[](#author)

Alex Gisby: [GitHub](http://github.com/alexgisby), [Twitter](http://twitter.com/alexgisby)

License
-------

[](#license)

[MIT](http://github.com/solution10/sql/tree/master/LICENSE.md)

Contributing
------------

[](#contributing)

[Contributors Notes](http://github.com/solution10/sql/tree/master/CONTRIBUTING.md)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

3950d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/231595?v=4)[Alex Gisby](/maintainers/alexgisby)[@alexgisby](https://github.com/alexgisby)

---

Top Contributors

[![alexgisby](https://avatars.githubusercontent.com/u/231595?v=4)](https://github.com/alexgisby "alexgisby (18 commits)")

---

Tags

composer-packagesdatabasephpsqldatabasesqlcomponent

### Embed Badge

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

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

###  Alternatives

[paragonie/easydb

Easy-to-use database abstraction

744273.4k23](/packages/paragonie-easydb)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[davmixcool/php-dbcloud

Easily backup PostgreSql or MySql database to the cloud

111.5k](/packages/davmixcool-php-dbcloud)

PHPackages © 2026

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