{"id":16463779,"url":"https://github.com/bpolaszek/simple-dbal","last_synced_at":"2025-10-27T10:31:29.734Z","repository":{"id":62493275,"uuid":"91696062","full_name":"bpolaszek/simple-dbal","owner":"bpolaszek","description":"Unified OOP API for PDO/Mysqli.","archived":false,"fork":false,"pushed_at":"2020-10-23T09:54:40.000Z","size":64,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-02T01:21:07.922Z","etag":null,"topics":["database","mysql","mysqli","pdo","php"],"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/bpolaszek.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-05-18T13:23:29.000Z","updated_at":"2020-07-19T09:14:59.000Z","dependencies_parsed_at":"2022-11-02T11:17:40.230Z","dependency_job_id":null,"html_url":"https://github.com/bpolaszek/simple-dbal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpolaszek%2Fsimple-dbal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpolaszek%2Fsimple-dbal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpolaszek%2Fsimple-dbal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpolaszek%2Fsimple-dbal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpolaszek","download_url":"https://codeload.github.com/bpolaszek/simple-dbal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861471,"owners_count":16555994,"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":["database","mysql","mysqli","pdo","php"],"created_at":"2024-10-11T11:15:34.054Z","updated_at":"2025-10-27T10:31:29.430Z","avatar_url":"https://github.com/bpolaszek.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/bentools/simple-dbal/v/stable)](https://packagist.org/packages/bentools/simple-dbal)\n[![License](https://poser.pugx.org/bentools/simple-dbal/license)](https://packagist.org/packages/bentools/simple-dbal)\n[![Quality Score](https://img.shields.io/scrutinizer/g/bpolaszek/simple-dbal.svg?style=flat-square)](https://scrutinizer-ci.com/g/bpolaszek/simple-dbal)\n[![Total Downloads](https://poser.pugx.org/bentools/simple-dbal/downloads)](https://packagist.org/packages/bentools/simple-dbal)\n\n# SimpleDBAL\nA modern wrapper on top of PDO and Mysqli, written in PHP7.1. It aims at exposing the same API regardless of the one your project uses.\n\nIntroduction\n------------\nPHP offers 2 different APIs to connect to a SQL database: `PDO` and `mysqli` (we won't talk about `mysql_*` functions since they're deprecated). Both do more or less the same thing, but:\n\n* Their API are completely different (different method names and signatures)\n* They both have their own pros and cons.\n* Some features of one are missing in the other.\n\nThis library exposes an API that can be used by any of them, transparently, in a more modern approach (OOP, iterators, return types, etc). \n\nThis also means you can switch from `PDO` to `mysqli` and vice-versa without having to rewrite your whole code.\n\nFrom my personnal experience, I was used to `PDO` and was forced to deal with `mysqli` in another project and it was really messy.\n\nOverview\n--------\n\n```php\nuse BenTools\\SimpleDBAL\\Model\\Credentials;\nuse BenTools\\SimpleDBAL\\Model\\SimpleDBAL;\n\n$credentials = new Credentials('localhost', 'user', 'password', 'database');\n$cnx         = SimpleDBAL::factory($credentials, SimpleDBAL::PDO);\n$query       = \"SELECT `id`, `name` FROM guys WHERE created_at \u003e ?\";\nforeach ($cnx-\u003eexecute($query, [new DateTime('-1 month')]) as $item) {\n    var_dump($item['name']);\n}\n```\n\nAdditionnal features\n--------------------\n* On-the-fly parameter binding for prepared statements (simply pass an array of arguments after the query)\n* `DateTimeInterface` objects automatic binding (formats to YYYY-MM-DD HH:ii:ss)\n* [Asynchronous queries](doc/03-AsynchronousQueries.md) (Promises)\n* [Parallel queries](doc/03-AsynchronousQueries.md#parallel-queries)\n* Support for named parameters in prepared statements for `mysqli` (polyfill with regexps - experimental feature)\n* Can [silently reconnect](doc/02-Configuration.md) after a lost connection\n\nThe `Result` object\n------------------\nEvery query sent to the adapter will return a `BenTools\\SimpleDBAL\\Contract\\ResultInterface` object.\n\nFor _SELECT_ queries, use the following methods:\n* `$result-\u003easArray()` to fetch an array containing the whole resultset\n* `$result-\u003easRow()` to fetch the 1st row of the resultset, as an associative array\n* `$result-\u003easList()` to fetch the 1st column of the resultset, as a sequential array\n* `$result-\u003easValue()` to fetch a single value (i.e the 1st column of the 1st row)\n* `foreach ($result as $row)` to iterate over the resultset (uses lazy-loading)\n* `count($result)` to return the number of rows of the resultset.\n\nFor _INSERT_ / _UPDATE_ / _DELETE_ queries, use the following methods:\n* `count($result)` to return the number of affected rows\n* `$result-\u003egetLastInsertId()` to get the id of the last inserted row or sequence value.\n\nInstallation\n------------\n```\ncomposer require bentools/simple-dbal\n```\n\nTests\n-----\n```\n./vendor/bin/phpunit\n```\n\nDocumentation\n-----\n\n[Getting started](doc/01-GettingStarted.md)\n\n[Configuring auto-reconnect](doc/02-Configuration.md)\n\n[Asynchronous and parallel queries](doc/03-AsynchronousQueries.md)\n\n[Connection pools](doc/04-ConnectionPools.md)\n\n[Known Issues](doc/05-KnownIssues.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpolaszek%2Fsimple-dbal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpolaszek%2Fsimple-dbal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpolaszek%2Fsimple-dbal/lists"}