PHPackages                             threeletters/supersql - 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. threeletters/supersql

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

threeletters/supersql
=====================

SlickInject and Medoo on steroids - The most advanced and lightweight library of its kind.

1.1.6(7y ago)15335[1 PRs](https://github.com/ThreeLetters/SuperSQL/pulls)MITPHPPHP &gt;=5.4

Since Aug 18Pushed 7y ago2 watchersCompare

[ Source](https://github.com/ThreeLetters/SuperSQL)[ Packagist](https://packagist.org/packages/threeletters/supersql)[ Docs](https://threeletters.github.io/SuperSQL/)[ RSS](/packages/threeletters-supersql/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)DependenciesVersions (6)Used By (0)

SuperSQL
========

[](#supersql)

[![SuperSQL](https://camo.githubusercontent.com/cd5c33e24bb5456efa174a48eeb0d0343e89d9f18e44bdae0528986f53f52f8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537570657253514c2d76312e312e352d627269676874677265656e2e737667)](https://camo.githubusercontent.com/cd5c33e24bb5456efa174a48eeb0d0343e89d9f18e44bdae0528986f53f52f8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537570657253514c2d76312e312e352d627269676874677265656e2e737667)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/ThreeLetters/SuperSQL/master/LICENSE)[![Docs](https://camo.githubusercontent.com/789bbb19a5f9ca31c395068cd631ddfca2b3e12506d2746a82c22a4da8e82da9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63732d4769746875622d626c75652e737667)](https://threeletters.github.io/SuperSQL)[![GitHub stars](https://camo.githubusercontent.com/d75d8639fdbefd257bc83007eaae54f372af9bcc4ba1b8b5fe70295240d50ac5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f54687265654c6574746572732f537570657253514c2e737667)](https://github.com/ThreeLetters/SuperSQL/stargazers)[![GitHub forks](https://camo.githubusercontent.com/e96b735b548198e23dfd25cdd50b9f7af1b7082a75154c77eff486495792c0d1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f54687265654c6574746572732f537570657253514c2e737667)](https://github.com/ThreeLetters/SuperSQL/network)

A light, efficient and powerful php sql database framework. Allows you to quickly and securely develop anything using SQL databases.

Purpose
-------

[](#purpose)

1. To provide a very fast and efficient way to use SQL databases.
2. To provide an easy way to use SQL databases safely.

### Main Features

[](#main-features)

1. Very small - 27.4KB one file (Unminified, `dist/SuperSQL.php`. Minified version: 12.4KB)
    - You can also choose whether you want an optional helper class.
2. Simple and easy - Very easy to learn. SuperSQL was designed to be easy and simple, to the point that a noob can use it.
    - Straight forward syntax `SELECT * FROM `table` ` is `db->select("table");`
    - String syntax is standardised. Its allways `'[operator1][op2][op3...]column[alias][type]'=>value`
3. Compatability - Supports all major SQL databases
    - Uses the [PDO](http://php.net/manual/en/book.pdo.php) API for widespread support
4. Efficiency - This module was built with speed and efficiency in mind.
    - Internal optimizations to make sure there is little overhead as possible
    - Dynamic SQLResponse class so you only fetch a row when you use it (`$response[0]` will only fetch the first row)
5. Complexity - This module allows you to make all kinds of complex queries.
    - Multi-table queries to execute queries on multiple tables at once
    - Multi-value queries to execute queries with multiple values
    - Templates to pass sets of data in as a group
    - Type casting and aliases
    - DISTINCT, GROUP, LIMIT/OFFSET, INSERT \[INTO\], and more supported
    - Raw input available
6. Security - This module prevents SQL injections, so hackers bye bye!
    - Uses PDO's prepare/bindParam/execute system with types
7. Availability &amp; Integration - This module is FREE. Licensed under the [MIT license](https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE).
    - Use it as you wish! Only remember to give credit.
    - Also available on composer

Usage
-----

[](#usage)

You may either

1. Use the built file ([/dist/SuperSQL.php](https://github.com/ThreeLetters/SuperSQL/blob/master/dist/SuperSQL.php) - preferred)
2. Use the library (Autoload all in `SuperSQL/`, we also provide a [simple loader](https://github.com/ThreeLetters/SuperSQL/blob/master/autoload.php))
3. Use the [composer package](https://packagist.org/packages/threeletters/supersql) (`composer require threeletters/supersql`)

```
new SuperSQL($dsn,$user,$pass);
```

```
use SuperSQL\SuperSQL;

// MySql setup
$host = "localhost";
$db = "test";
$user = "root";
$pass = "1234";

$dsn = "mysql:host=$host;port=3306;dbname=$db;charset=utf8";
$SuperSQL = new SuperSQL($dsn,$user,$pass);
```

```
use SuperSQL\SQLHelper;

// MySql setup
$host = "localhost";
$db = "test";
$user = "root";
$pass = "1234";

$SuperSQL = SQLHelper::connect($host, $db, $user,$pass);
```

```
$result = $SuperSQL->select("test",[],[
    "condition" => 12345,
    "[||][&&]" => [
        "something" => "value",
        "anotherthing" => "val"
    ]
]); // SELECT * FROM `test` WHERE `condition` = 12345 OR (`something` = 'value' AND `anotherthing` = 'val')

if (!$result->error()) {
foreach ($result as $val) { // NOTE, $result is NOT an array
    echo $val;
}
} else {
echo json_encode($result->error());
}
```

Build
-----

[](#build)

To build this library, you need [NodeJS](https://nodejs.org/en/). Then execute `builder.js`

> node builder.js

It will build to `/dist/SuperSQL*.php`

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

[](#documentation)

Full documentation is here:

[![supersql.tk](https://user-images.githubusercontent.com/13282284/29477701-7e6385c6-8437-11e7-9e87-74a12393c49a.png)](https://user-images.githubusercontent.com/13282284/29477701-7e6385c6-8437-11e7-9e87-74a12393c49a.png)

FAQ
---

[](#faq)

**What is a SQLResponse?**

SQLResponse is the object returned from a query. It implements the ArrayAccess and Iterator interfaces, and so can be accessed and iterated through like an array. When you do access a row or iterate through, a function is called and fetches the row from the database, and caches it. If all rows are fetched, then the connection is deleted as it does not have to be used anymore.

**Whats the difference between this and Medoo?**

While on the most basic level, SuperSQL and Medoo are the same, they are quite different.

- Response class - SuperSQL has a response class to access crucial information, such as errors
- Helper - SuperSQL comes with an optional advanced helper class, with helper functions, while medoo has a simple one built right in.
- Smaller &amp; lightweight - SuperSQL is smaller than Medoo, yet has more features.
- Development - SuperSQL's code is well structured and it is commented - so you can understand it more
- SuperSQL is faster - Using xdebug, we found that superSQL's parser is faster than medoo's. (x1000,100%)
- SuperSQL is less confusing. (EG, `SELECT * FROM `table` ` is just `$SuperSQL->select('table');`)
- SuperSQL has more features - (EG, multi-querying, dynamic responses, distinct, etc...)

**How fast is superSQL compared to Medoo?**

[speed](https://user-images.githubusercontent.com/13282284/30243699-b4c76e32-957d-11e7-9bdb-ec96f53816b1.png)

**Whats the difference between this an SlickInject?**

SuperSQL uses the same concepts and design as SlickInject. However, SuperSQL has more complex features.

**Why use PDO instead of Mysqli?**

PDO is much more versatile than mysqli. Main reason is because it supports so many different databases while mysqli only supports one.

**How did you make the documentation?**

The nice documentation was created using [Slate - Check it out](https://github.com/lord/slate).

Special thanks
--------------

[](#special-thanks)

- [@LegitSoulja](https://github.com/LegitSoulja) - [SlickInject](https://github.com/LegitSoulja/SlickInject),
- [@catfan](https://github.com/catfan) - [Medoo](https://github.com/catfan/Medoo)
- [Slate](https://github.com/lord/slate) (Documentation)

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

[](#contributing)

Contributing is open. If you want to contribute, make a pull request. Please use the [PEAR format](https://pear.php.net/manual/en/standards.php).

> NOTE: please do not do `[]` for array. Please use `array()` instead. This is for backwards compatability.

License
-------

[](#license)

```
MIT License

Copyright (c) 2017 Andrew S (Andrews54757_at_gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 99.6% 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

Total

5

Last Release

2899d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13282284?v=4)[Andrew S](/maintainers/Andrews54757)[@Andrews54757](https://github.com/Andrews54757)

---

Top Contributors

[![Andrews54757](https://avatars.githubusercontent.com/u/13282284?v=4)](https://github.com/Andrews54757 "Andrews54757 (233 commits)")[![abbadon1334](https://avatars.githubusercontent.com/u/5801824?v=4)](https://github.com/abbadon1334 "abbadon1334 (1 commits)")

---

Tags

pdosqlsql-databasedatabasemysqlsqladvancedlightweightsmall

### Embed Badge

![Health badge](/badges/threeletters-supersql/health.svg)

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

###  Alternatives

[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M203](/packages/catfan-medoo)[rah/danpu

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

62414.3k11](/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)
