{"id":22425344,"url":"https://github.com/phppkg/pdox","last_synced_at":"2026-05-17T18:05:00.861Z","repository":{"id":56991495,"uuid":"114199469","full_name":"phppkg/pdox","owner":"phppkg","description":"a lightweight database client by php PDO","archived":false,"fork":false,"pushed_at":"2022-05-11T13:45:26.000Z","size":240,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-18T17:34:05.597Z","etag":null,"topics":["database","database-connector","pdo","pdo-wrapper"],"latest_commit_sha":null,"homepage":"https://phppkg.github.io/pdox/","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/phppkg.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":"2017-12-14T03:47:03.000Z","updated_at":"2023-11-11T10:34:32.000Z","dependencies_parsed_at":"2022-08-24T00:50:52.074Z","dependency_job_id":null,"html_url":"https://github.com/phppkg/pdox","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/phppkg/pdox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fpdox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fpdox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fpdox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fpdox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phppkg","download_url":"https://codeload.github.com/phppkg/pdox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fpdox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33149519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"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","database-connector","pdo","pdo-wrapper"],"created_at":"2024-12-05T19:13:52.075Z","updated_at":"2026-05-17T18:05:00.845Z","avatar_url":"https://github.com/phppkg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple db client\n\n[![License](https://img.shields.io/packagist/l/phppkg/pdox.svg?style=flat-square)](LICENSE)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/phppkg/pdox)\n[![Latest Stable Version](http://img.shields.io/packagist/v/phppkg/pdox.svg)](https://packagist.org/packages/phppkg/pdox)\n\nSimple database client for mysql,sqlite by PDO\n\n- **github** https://github.com/phppkg/pdox.git\n\n## Install\n\n- By composer require\n\n```bash\ncomposer require phppkg/pdox\n```\n\n- By composer.json\n\n```json\n{\n  \"require\": {\n    \"phppkg/pdox\": \"~1.0.0\"\n  }\n}\n```\n\n- Pull directly\n\n```bash\ngit clone https://github.com/phppkg/pdox.git\n```\n\n## Usage\n\n### create connection\n\n```php\nuse PhpComp\\PdoX\\PdoX;\n\n$db = PdoX::create([\n    // open debug, will record query logs.\n    'debug' =\u003e 1,\n    \n    'driver' =\u003e 'mysql', // 'sqlite' 'pgsql' 'mssql'\n    'host' =\u003e 'localhost',\n    'user' =\u003e 'root',\n    'password' =\u003e 'password',\n    'database' =\u003e 'test',\n]);\n\n// add event listeners.\n\n$db-\u003eon(PdoX::CONNECT, function ($db) {\n    echo \"connect database success\\n\";\n});\n$db-\u003eon(PdoX::BEFORE_EXECUTE, function ($sql) {\n    echo \"Will run SQL: $sql\\n\";\n});\n$db-\u003eon(PdoX::DISCONNECT, function ($db) {\n    echo \"disconnect database success\\n\";\n});\n```\n\n### basic\n\n```php\n$db-\u003eexec('CREATE TABLE IF NOT EXISTS `user` (\n   `id` INT(11) NOT NULL AUTO_INCREMENT,\n   `username` VARCHAR(32) NOT NULL,\n   `nickname` VARCHAR(32),\n   primary key(id)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;');\n\n// fetch all\n$ret = $db-\u003efetchAll('show tables');\nvar_dump($ret);\n```\n\n### insert\n\n```php\n// insert one\n$ret = $db-\u003einsert('user', [\n    'username' =\u003e 'tom',\n    'nickname' =\u003e 'tom-nick',\n], [\n    'returnSql' =\u003e 1,\n]);\nvar_dump($ret);\n\n// batch insert\n$ret = $db-\u003einsertBatch('user',[\n    [\n        'username' =\u003e 'tom',\n        'nickname' =\u003e 'tom-nick',\n    ],\n    [\n        'username' =\u003e 'tom1',\n        'nickname' =\u003e 'tom-nick2',\n    ],\n], [\n    'returnSql' =\u003e 1,\n]);\nvar_dump($ret);\n```\n\n### query\n\n```php\n// find one\n// SQL: SELECT * FROM `user` WHERE `id`= ? LIMIT 1\n$ret = $db-\u003equeryOne('user', ['id' =\u003e 3], '*', [\n    'fetchType' =\u003e 'assoc',\n    'returnSql' =\u003e 1,\n]);\nvar_dump($ret);\n\n\n// find all\n// SQL: SELECT * FROM `user` WHERE `username` like ? LIMIT 1000\n$ret = $db-\u003equeryAll('user', [ ['username', 'like', '%tes%'] ], '*', [\n    'fetchType' =\u003e 'assoc',\n    'limit' =\u003e 10,\n    'returnSql' =\u003e 1,\n]);\nvar_dump($ret);\n\n// more conditions\n$ret = $db-\u003equeryAll('user', [\n     'userId' =\u003e 23,      // 'AND `userId` = 23'\n     'title' =\u003e 'test',  // value will auto add quote, equal to \"AND title = 'test'\"\n     'status' =\u003e [1, 2], // status IN (1,2)\n     \n     ['publishAt', '\u003e', '0'],  // ==\u003e 'AND `publishAt` \u003e 0'\n     ['createdAt', '\u003c=', 1345665427, 'OR'],  // ==\u003e 'OR `createdAt` \u003c= 1345665427'\n     ['id', 'IN' ,[4,5,56]],   // ==\u003e '`id` IN ('4','5','56')'\n     ['id', 'NOT IN', [4,5,56]], // ==\u003e '`id` NOT IN ('4','5','56')'\n     \n     // a closure\n     function () {\n         return 'a \u003c 5 OR b \u003e 6';\n     }\n]);\n\n// SQL: SELECT * FROM `user` WHERE \"name\"= ? OR ( \"type\"= ? AND \"createAt\" \u003c= ? ) AND \"status\" IN ('1','2')\n$ret = $db-\u003equeryAll('user', [\n  'name' =\u003e 'tom',\n  'or' =\u003e '(',\n  'type' =\u003e 'admin',\n  ['createAt', '\u003c=', \\date('Y-m-d H:i:s')],\n  ')',\n  'status' =\u003e [1,2]\n]);\n```\n\n### update\n\n```php\n$ret = $db-\u003eupdate('user', ['id' =\u003e 2], [\n    'username' =\u003e 'tom',\n    'nickname' =\u003e 'tom-nick',\n], [\n    'returnSql' =\u003e 1,\n]);\nvar_dump($ret);\n```\n\n### delete\n\n```php\n$ret = $db-\u003edelete('user', ['id' =\u003e 2], [\n    'returnSql' =\u003e 1,\n    'limit' =\u003e 1,\n]);\nvar_dump($ret);\n```\n\n### get query logs\n\n```php\nvar_dump($db-\u003egetQueryLogs());\n```\n\n## Methods docs\n\n\u003e https://phppkg.github.io/pdox/classes/master/Inhere/PdoX/PdoX.html\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fpdox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphppkg%2Fpdox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fpdox/lists"}