{"id":20139062,"url":"https://github.com/threeletters/supersql","last_synced_at":"2025-04-09T18:21:39.743Z","repository":{"id":57069226,"uuid":"99179317","full_name":"ThreeLetters/SuperSQL","owner":"ThreeLetters","description":"A light, efficient and powerful php sql database framework. Allows you to quickly and securely develop anything using sql databases.","archived":false,"fork":false,"pushed_at":"2019-02-07T22:22:36.000Z","size":755,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T20:22:12.651Z","etag":null,"topics":["pdo","sql","sql-database"],"latest_commit_sha":null,"homepage":"https://threeletters.github.io/SuperSQL/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThreeLetters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-03T02:01:25.000Z","updated_at":"2024-08-17T02:30:02.000Z","dependencies_parsed_at":"2022-08-24T10:20:41.135Z","dependency_job_id":null,"html_url":"https://github.com/ThreeLetters/SuperSQL","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FSuperSQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FSuperSQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FSuperSQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FSuperSQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThreeLetters","download_url":"https://codeload.github.com/ThreeLetters/SuperSQL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085593,"owners_count":21045183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pdo","sql","sql-database"],"created_at":"2024-11-13T21:43:50.630Z","updated_at":"2025-04-09T18:21:39.696Z","avatar_url":"https://github.com/ThreeLetters.png","language":"PHP","readme":"# SuperSQL\n![SuperSQL](https://img.shields.io/badge/SuperSQL-v1.1.5-brightgreen.svg)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ThreeLetters/SuperSQL/master/LICENSE)\n[![Docs](https://img.shields.io/badge/Docs-Github-blue.svg)](https://threeletters.github.io/SuperSQL)\n[![GitHub stars](https://img.shields.io/github/stars/ThreeLetters/SuperSQL.svg)](https://github.com/ThreeLetters/SuperSQL/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/ThreeLetters/SuperSQL.svg)](https://github.com/ThreeLetters/SuperSQL/network)\n\n\nA light, efficient and powerful php sql database framework. Allows you to quickly and securely develop anything using SQL databases.\n\n## Purpose\n\n1. To provide a very fast and efficient way to use SQL databases.\n2. To provide an easy way to use SQL databases safely.\n\n### Main Features\n\n1. Very small - 27.4KB one file (Unminified, `dist/SuperSQL.php`. Minified version: 12.4KB)\n    * You can also choose whether you want an optional helper class.\n2. Simple and easy - Very easy to learn. SuperSQL was designed to be easy and simple, to the point that a noob can use it.\n    * Straight forward syntax ```SELECT * FROM `table` ``` is `db-\u003eselect(\"table\");`\n    * String syntax is standardised. Its allways `'[operator1][op2][op3...]column[alias][type]'=\u003evalue`\n3. Compatability - Supports all major SQL databases\n    * Uses the [PDO](http://php.net/manual/en/book.pdo.php) API for widespread support\n4. Efficiency - This module was built with speed and efficiency in mind.\n    * Internal optimizations to make sure there is little overhead as possible\n    * Dynamic SQLResponse class so you only fetch a row when you use it (`$response[0]` will only fetch the first row)\n5. Complexity - This module allows you to make all kinds of complex queries.\n    * Multi-table queries to execute queries on multiple tables at once\n    * Multi-value queries to execute queries with multiple values\n    * Templates to pass sets of data in as a group\n    * Type casting and aliases\n    * DISTINCT, GROUP, LIMIT/OFFSET, INSERT [INTO], and more supported\n    * Raw input available\n6. Security - This module prevents SQL injections, so hackers bye bye!\n    * Uses PDO's prepare/bindParam/execute system with types\n7. Availability \u0026 Integration - This module is FREE. Licensed under the [MIT license](https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE).\n    * Use it as you wish! Only remember to give credit.\n    * Also available on composer\n\n## Usage\nYou may either\n\n1. Use the built file ([/dist/SuperSQL.php](https://github.com/ThreeLetters/SuperSQL/blob/master/dist/SuperSQL.php) - preferred)\n2. Use the library (Autoload all in `SuperSQL/`, we also provide a [simple loader](https://github.com/ThreeLetters/SuperSQL/blob/master/autoload.php))\n3. Use the [composer package](https://packagist.org/packages/threeletters/supersql) (`composer require threeletters/supersql`)\n\n```php\nnew SuperSQL($dsn,$user,$pass);\n```\n```php\nuse SuperSQL\\SuperSQL;\n\n// MySql setup\n$host = \"localhost\";\n$db = \"test\";\n$user = \"root\";\n$pass = \"1234\";\n\n$dsn = \"mysql:host=$host;port=3306;dbname=$db;charset=utf8\";\n$SuperSQL = new SuperSQL($dsn,$user,$pass);\n```\n\n```php\nuse SuperSQL\\SQLHelper;\n\n// MySql setup\n$host = \"localhost\";\n$db = \"test\";\n$user = \"root\";\n$pass = \"1234\";\n\n$SuperSQL = SQLHelper::connect($host, $db, $user,$pass);\n```\n```php\n$result = $SuperSQL-\u003eselect(\"test\",[],[\n    \"condition\" =\u003e 12345,\n    \"[||][\u0026\u0026]\" =\u003e [\n        \"something\" =\u003e \"value\",\n        \"anotherthing\" =\u003e \"val\"\n    ]\n]); // SELECT * FROM `test` WHERE `condition` = 12345 OR (`something` = 'value' AND `anotherthing` = 'val')\n\nif (!$result-\u003eerror()) {\nforeach ($result as $val) { // NOTE, $result is NOT an array\n    echo $val;\n}\n} else {\necho json_encode($result-\u003eerror());\n}\n```\n\n## Build\nTo build this library, you need [NodeJS](https://nodejs.org/en/). Then execute `builder.js`\n\n\u003e node builder.js\n\nIt will build to `/dist/SuperSQL*.php`\n\n## Documentation\n\nFull documentation is here: https://threeletters.github.io/SuperSQL\n\n![supersql.tk](https://user-images.githubusercontent.com/13282284/29477701-7e6385c6-8437-11e7-9e87-74a12393c49a.png)\n\n## FAQ\n\n**What is a SQLResponse?**\n\nSQLResponse 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.\n\n**Whats the difference between this and Medoo?**\n\nWhile on the most basic level, SuperSQL and Medoo are the same, they are quite different.\n\n* Response class - SuperSQL has a response class to access crucial information, such as errors\n* Helper - SuperSQL comes with an optional advanced helper class, with helper functions, while medoo has a simple one built right in.\n* Smaller \u0026 lightweight - SuperSQL is smaller than Medoo, yet has more features.\n* Development - SuperSQL's code is well structured and it is commented - so you can understand it more\n* SuperSQL is faster - Using xdebug, we found that superSQL's parser is faster than medoo's. (x1000,100%)\n* SuperSQL is less confusing. (EG, ``SELECT * FROM `table` `` is just `$SuperSQL-\u003eselect('table');`)\n* SuperSQL has more features - (EG, multi-querying, dynamic responses, distinct, etc...)\n\n**How fast is superSQL compared to Medoo?**\n\n[speed](https://user-images.githubusercontent.com/13282284/30243699-b4c76e32-957d-11e7-9bdb-ec96f53816b1.png)\n\n**Whats the difference between this an SlickInject?**\n\nSuperSQL uses the same concepts and design as SlickInject. However, SuperSQL has more complex features.\n\n**Why use PDO instead of Mysqli?**\n\nPDO is much more versatile than mysqli. Main reason is because it supports so many different databases while mysqli only supports one.\n\n**How did you make the documentation?**\n\nThe nice documentation was created using [Slate - Check it out](https://github.com/lord/slate).\n\n## Special thanks\n* [@LegitSoulja](https://github.com/LegitSoulja) - [SlickInject](https://github.com/LegitSoulja/SlickInject), \n* [@catfan](https://github.com/catfan) - [Medoo](https://github.com/catfan/Medoo)\n* [Slate](https://github.com/lord/slate) (Documentation)\n\n## Contributing\nContributing is open. If you want to contribute, make a pull request. Please use the [PEAR format](https://pear.php.net/manual/en/standards.php).\n\n\u003e NOTE: \n\u003e please do not do `[]` for array. Please use `array()` instead. This is for backwards compatability.\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2017 Andrew S (Andrews54757_at_gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeletters%2Fsupersql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreeletters%2Fsupersql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeletters%2Fsupersql/lists"}