2017 © Pedro Peláez
 

framework supersql

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

image

threeletters/supersql

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

  • Tuesday, July 24, 2018
  • by Andrews54757
  • Repository
  • 2 Watchers
  • 6 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

SuperSQL

SuperSQL GitHub license Docs GitHub stars GitHub forks, (*1)

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

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

  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 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 & Integration - This module is FREE. Licensed under the MIT license.
    • Use it as you wish! Only remember to give credit.
    • Also available on composer

Usage

You may either, (*3)

  1. Use the built file (/dist/SuperSQL.php - preferred)
  2. Use the library (Autoload all in SuperSQL/, we also provide a simple loader)
  3. Use the composer package (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);



```php use SuperSQL\SQLHelper; // MySql setup $host = "localhost"; $db = "test"; $user = "root"; $pass = "1234"; $SuperSQL = SQLHelper::connect($host, $db, $user,$pass);
```php $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 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 Full documentation is here: https://threeletters.github.io/SuperSQL ![supersql.tk](https://user-images.githubusercontent.com/13282284/29477701-7e6385c6-8437-11e7-9e87-74a12393c49a.png) ## 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 & 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 * [@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 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
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.

The Versions

24/07 2018

dev-master

9999999-dev https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

24/07 2018

1.1.6

1.1.6.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

06/12 2017

1.1.5

1.1.5.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

10/09 2017

1.1.0

1.1.0.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

31/08 2017

1.0.8

1.0.8.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

18/08 2017

1.0.5

1.0.5.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small

18/08 2017

1.0.3

1.0.3.0 https://threeletters.github.io/SuperSQL/

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

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-pdo *

 

by Andrew S

database sql lightweight advanced mysql small