{"id":20929150,"url":"https://github.com/quickstartlibs/db","last_synced_at":"2025-09-04T00:06:23.817Z","repository":{"id":57052833,"uuid":"41853186","full_name":"QuickStartLibs/DB","owner":"QuickStartLibs","description":"Stash Queries - A thin and simple yet elegant database abstraction layer around PDO.","archived":false,"fork":false,"pushed_at":"2018-04-17T13:45:24.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T11:39:00.732Z","etag":null,"topics":["database","injection","mysql","pdo","pdo-replacement","pdo-wrapper","persistent-connections","php","queries","query-builder","querying","sql","stash-queries","stash-query"],"latest_commit_sha":null,"homepage":"http://skyfirephp.com/Database","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QuickStartLibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-03T10:05:22.000Z","updated_at":"2022-06-10T12:30:18.000Z","dependencies_parsed_at":"2022-08-24T05:10:15.962Z","dependency_job_id":null,"html_url":"https://github.com/QuickStartLibs/DB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QuickStartLibs/DB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuickStartLibs%2FDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuickStartLibs%2FDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuickStartLibs%2FDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuickStartLibs%2FDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuickStartLibs","download_url":"https://codeload.github.com/QuickStartLibs/DB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuickStartLibs%2FDB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273529562,"owners_count":25121830,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["database","injection","mysql","pdo","pdo-replacement","pdo-wrapper","persistent-connections","php","queries","query-builder","querying","sql","stash-queries","stash-query"],"created_at":"2024-11-18T21:17:32.932Z","updated_at":"2025-09-04T00:06:23.781Z","avatar_url":"https://github.com/QuickStartLibs.png","language":"PHP","readme":"# Stash Queries\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"http://travisfont.com/images/stash-queries-carbon.png\" width=\"990\" height=\"405\" /\u003e\n\u003c/p\u003e\n\nStash Queries is a PHP SQL library providing an easy, eloquent, and fluent yet expressive way to select, create, update, and delete SQL records. Overall, it's a simple thin wrapper around PHP's PDO database abstraction layer. The layer fluency provides a direct way to interact with SQL using actual SQL files.\n\nThis library is originally part of Skyfire's PHP framework database layer known as *DB* service.\n\n_Note:_ Stash Queries isn't an ORM in any way or shape, but rather a wrapper replacement for native PDO.\n\n_Currently Stash Queries works only with MySQL and PostgreSQL databases. Support for other platforms is planned for later releases._\n\n## Requirements\n\n- PHP \u003e=5.6+\n- PDO_MYSQL PHP extensions\n\n*Due to security and feature reasons, PHP 5.6 is required.*\n\u003cbr/\u003e*At most by standards, you should be using a PHP version above or at 5.6 by now.*\n\n## Code Examples\n\n```php\n// setting the DB display encoding type (if needed)\nFixCollation::charset('utf-8', FixCollation::TEXT_HTML);\n\n// setting Database credentials\nDB::define('stash_dir',   getcwd()); // or dirname(__FILE__)\nDB::define('host',       'localhost');\nDB::define('dbname',     'test_db1');\nDB::define('dbuser',     'root');\nDB::define('dbpassword', '');\n\n\n// SQL select query (with prepare variables)\n$prepare = array\n(\n    'label' =\u003e 'test'\n);\n$data = DB::select('get.HomeTextByLabel')-\u003eprepare($prepare);\nvar_dump($data);\n\n\n// SQL simple select query\n$data = DB::select('get.AllHomeTextData')-\u003eexecute();\nvar_dump($data);\n\n\n// raw SQL query (with prepare variables)\n$data = DB::query('SELECT * FROM test WHERE data IS NOT NULL AND id \u003e :count AND data != :text', array\n(\n    ':id'   =\u003e 10,\n    ':text' =\u003e 'test'\n))-\u003eexecute();\nvar_dump($data);\n\n\n// displays the prepare update statement in plain text (ideal for debugging queries)\n$query = DB::update('PostfromTestById')-\u003etext($prepare);\necho $query;\n```\n\n## Injections:\n\nTo assign dynamic variables outside queries without binding (secured injections) such as table names and fields which are not possible by PDO binding:\n```php\n$data = DB::select('get.fieldData.byId')-\u003einject(array\n(\n    'field' =\u003e $data-\u003efield,\n    'table' =\u003e $table_name\n))-\u003eprepare(array('id' =\u003e (int) $record-\u003eid));\n```\n\n## Persistent Connections:\n\nTo have persistent connections for all queries, this can be done by defining it in the DB configurations - as such:\n```php\nDB::define('persistent', TRUE);\n// DB::define('persistent', 'yes');\n```\nBoth examples above work perfectly, only TRUE or 'yes' are allowed.\n\n\n## Creating Query Folders\n\nIf query don't exist (or uncertainity of their existance), calling the following function will create the query folders if they do not exist. The function will return back FALSE, if no directories were created, or the count of (e.g. 4) directories created.\n```php\nDB::createQueryDirectories();\n```\nNote: It's important to place this function after all DB::define() calls.\n\n\n## Creating a database if not existing (shortcut)\n```php\nDB::createNotExist('database_name');\n```\nNote: It's important to place this function after all DB::define() calls.\n\n\n## Installation:\nInjecting the code mamually, you only have to include 'StashQueries.php' as such:\n```php\nrequire_once 'DB/StashQueries.php';\n```\nAlso, externally through composer by adding 'SkyfirePHP/DB' to composer dependencies in composer.json:\n```json\n{\n    \"require\": {\n        \"skyfirephp/db\": \"dev-master\"\n    }\n}\n```\n\n## License\n\nStash Queries is licensed under the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright 2015-2017 [Travis van der Font](http://travisfont.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickstartlibs%2Fdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquickstartlibs%2Fdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickstartlibs%2Fdb/lists"}