{"id":37264984,"url":"https://github.com/turbopixel/phpdo-database","last_synced_at":"2026-01-16T00:03:04.446Z","repository":{"id":57073681,"uuid":"117830496","full_name":"turbopixel/PHPDO-Database","owner":"turbopixel","description":"A simple php pdo database wrapper class with some helpers.","archived":false,"fork":false,"pushed_at":"2023-02-17T12:46:50.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-14T14:43:38.573Z","etag":null,"topics":["database","mysql","pdo-mysql","php","php7"],"latest_commit_sha":null,"homepage":"","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/turbopixel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-17T12:02:59.000Z","updated_at":"2023-07-09T19:48:28.000Z","dependencies_parsed_at":"2022-08-24T14:54:42.011Z","dependency_job_id":null,"html_url":"https://github.com/turbopixel/PHPDO-Database","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/turbopixel/PHPDO-Database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbopixel%2FPHPDO-Database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbopixel%2FPHPDO-Database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbopixel%2FPHPDO-Database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbopixel%2FPHPDO-Database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turbopixel","download_url":"https://codeload.github.com/turbopixel/PHPDO-Database/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbopixel%2FPHPDO-Database/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28474210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T22:27:41.514Z","status":"ssl_error","status_checked_at":"2026-01-15T21:54:47.910Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","mysql","pdo-mysql","php","php7"],"created_at":"2026-01-16T00:03:03.662Z","updated_at":"2026-01-16T00:03:04.437Z","avatar_url":"https://github.com/turbopixel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHPDO\n\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/turbopixel/PHPDO-Database)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/turbopixel/PHPDO-Database/blob/master/LICENSE)\n![GitHub contributors](https://img.shields.io/github/contributors/turbopixel/PHPDO-Database)\n![GitHub last commit](https://img.shields.io/github/last-commit/turbopixel/PHPDO-Database)\n[![packagist](https://badgen.net/packagist/v/turbopixel/PHPDO-Database)](https://packagist.org/packages/turbopixel/phpdo-database)\n\nA lightweight PHP PDO database singleton wrapper class.\n\nDocs and examples: [github.com/turbopixel/PHPDO-Database](https://github.com/turbopixel/PHPDO-Database)\n\n### Requirements\n\n* PHP 7.2+\n* MySQL/MariaDB\n\n### Install via composer\n\n```text\ncomposer require turbopixel/phpdo-database\n```\n\n## Example\n\n```php\nPHPDO::connect(\"database-server.com\", \"database_name\", \"user_name\", \"myPassword123\");\n\nPHPDO::get()-\u003equery(\"SELECT stars FROM github\")-\u003efetchAll();\n```\n\n## class PHPDO\n\n### Create database connection\n\n```php\n\\PHPDO\\PHPDO::connect(\"database-server.com\", \"database_name\", \"user_name\", \"myPassword123\");\n```\n\nAn existing PDO object can be set instead\n\n```php\n// $pdoObject = new PDO();\n\nPHPDO::setPdo($pdoObject);\n```\n\nAfter this, you can use the PHPDO class from everywhere.\n\n## Get instance\n\n**\\PHPDO\\PHPDO::get()** returns the PHPDO instance\n\n```php\n\\PHPDO\\PHPDO::get()\n```\n\nExample: Select rows\n\n```php\n\\PHPDO\\PHPDO::get()-\u003equery(\"SELECT * FROM github\")-\u003efetchAll();\n```\n\n**Get PDO instance**\n\n```php\n\\PHPDO\\PHPDO::get()-\u003egetPdo()\n```\n\n## Run MySQL query\n\n**query**\n\n```php\n\\PHPDO\\PHPDO::get()-\u003equery(\"SELECT id FROM user WHERE active = 1\");\nprint_r( $pdoStmnt-\u003efetch() );\n```\n\n**execute**\n\n```php\n\\PHPDO\\PHPDO::get()-\u003eexecute(\"UPDATE user SET active = 0 WHERE mail IS NULL\");\n```\n\n**Prepared Statement**\n\n```php\n\\PHPDO\\PHPDO::get()-\u003eprepare(\"UPDATE github SET stars = stars+1 WHERE id = :id\", [\"id\" =\u003e 1234]);\n```\n\n## Helper\n\n### fetch() - Select a single row\n\n```php\n\\PHPDO\\PHPDO::get()-\u003efetch(\"SELECT id FROM github WHERE id = :repo\", [\"repo\" =\u003e 553]);\n```\n\n`\\PHPDO\\PHPDO::get()-\u003efetch()` is a helper method and replace this:\n\n```php\n$rows  = [];\n$stmnt = \\PHPDO\\PHPDO::get()-\u003eprepare(\"SELECT * FROM github WHERE id = ?\", [\n  1234\n]);\n\nif($stmnt instanceof PDOStatement){\n  $rows = $stmnt-\u003efetchAll();\n}else{\n die(\"QUERY ERROR\");\n}\n\nprint_r($rows);\n```\n\n### fetchAll() - Select multiple rows\n\n```php\n\\PHPDO\\PHPDO::get()-\u003efetchAll(\"SELECT id FROM github WHERE id = :repo\", [\"repo\" =\u003e 553]);\n```\n\n### rowCount() - Count rows\n\n```php\n\\PHPDO\\PHPDO::get()-\u003erowCount(\"SELECT id FROM github WHERE id = :repo\", [\"repo\" =\u003e 553]);\n```\n\n### isTable() - Check table exists (MySQL only)\n\n```php\n\\PHPDO\\PHPDO::get()-\u003eisTable(\"user_settings\")\n```\n\n### findPrimaryIndexColumn() - Find table index column (MySQL only)\n\n```php\n\\PHPDO\\PHPDO::get()-\u003efindPrimaryIndexColumn(\"tablename\", \"databasename\")\n```\n\n## Internal class logging\n\nAll SQL Queries stored in PHPDO::$logs (array). Attribute `\\PHPDO\\PHPDO::$logging` must be `true`\n\n**Enable logging**\n\n```php\n\\PHPDO\\PHPDO::$logging = true;\n```\n\n**Get internal query logs**  \nGet query logs.\n\n```php\n\\PHPDO\\PHPDO::get()-\u003egetLog(); // returns an array\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbopixel%2Fphpdo-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturbopixel%2Fphpdo-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbopixel%2Fphpdo-database/lists"}