{"id":18838878,"url":"https://github.com/grizz-it/dbal-pdo","last_synced_at":"2026-04-29T08:33:54.921Z","repository":{"id":56983465,"uuid":"354290794","full_name":"grizz-it/dbal-pdo","owner":"grizz-it","description":"Database abstraction layer package implementing PDO","archived":false,"fork":false,"pushed_at":"2021-04-03T12:54:04.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T12:47:19.750Z","etag":null,"topics":["databases","dbal","pdo","php","sql"],"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/grizz-it.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-03T12:49:50.000Z","updated_at":"2021-05-26T03:24:30.000Z","dependencies_parsed_at":"2022-08-21T09:10:44.082Z","dependency_job_id":null,"html_url":"https://github.com/grizz-it/dbal-pdo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grizz-it/dbal-pdo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fdbal-pdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fdbal-pdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fdbal-pdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fdbal-pdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grizz-it","download_url":"https://codeload.github.com/grizz-it/dbal-pdo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fdbal-pdo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32417840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"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":["databases","dbal","pdo","php","sql"],"created_at":"2024-11-08T02:41:08.824Z","updated_at":"2026-04-29T08:33:54.898Z","avatar_url":"https://github.com/grizz-it.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/grizz-it/dbal-pdo.svg?branch=master)](https://travis-ci.com/grizz-it/dbal-pdo)\n\n# GrizzIT DBAL PDO\n\nGrizzIT DBAL PDO provides a PDO implementation for\n[GrizzIT DBAL](https://github.com/grizz-it/dbal). This package only implements\nthe database connection and transaction part.\n\n## Installation\n\nTo install the package run the following command:\n\n```\ncomposer require grizz-it/dbal-pdo\n```\n\n## Usage\n\n### Creating a connection\n\nTo establish a connection with the database through the\n`GrizzIt\\Dbal\\Pdo\\Component\\Connection\\PdoConnection` object, it is preferred to use the\nsupplied factory in the package.\n\nFirst of, initialize the factory by adding:\n```php\n\u003c?php\n\nuse GrizzIt\\Dbal\\Pdo\\Factory\\PdoConnectionFactory;\n\n$factory = new PdoConnectionFactory;\n```\n\nThen proceed to create an instance of `PdoConnection` by calling the `create` method.\n\n```php\n\u003c?php\n\n$connection = $factory-\u003ecreate(\n    'mysql:dbname=test;host=localhost',\n    'test',\n    'test'\n);\n```\n\nThe factory will then create a `PDO` object, inject it into the `PdoConnection`\nobject and return the connection object.\n\nThe create method has the following parameters:\n\n#### string $dsn\n\nThis parameter expects a DSN string.\nThe Data Source Name, or DSN, contains the information required to connect to\nthe database. An example of how to compose such a string for MySQL can be found\n[here](https://www.php.net/manual/en/ref.pdo-mysql.connection.php).\n\n#### string $username\n\nThis string expects the username of the database user through which you wish to\nconnect your application to the database.\n\n#### string $password (optional)\n\nThe password field expects the password for the previously mentioned user.\n\n#### array $options (optional)\n\nThis parameter expects driver specific connection options in key value pairs.\nThese can be found through the [PDO drivers](https://www.php.net/manual/en/pdo.drivers.php)\npage on PHP.net.\n\n#### array $attributes (optional)\n\nThis parameter expects PDO attributes to be set in key value pairs.\nThese options can be found [here](https://www.php.net/manual/en/pdo.setattribute.php).\nAll these options are immediately set on the PDO object after initialisation.\n\n### Calling the database\n\nAfter the connection has been established with the database it is possible to\nsend query objects to the `PdoConnection`, which will run their queries on the\ndatabase.\n\nAfter a query object is fully assembled it can be executed in the following ways:\n```php\n// Immediate call to the database.\n$result = $connection-\u003equery($queryObject);\n\n// Transactional call to the database.\n$connection-\u003estartTransaction();\n$result = $connection-\u003equery($queryObject);\n$connection-\u003ecommit();\n// It is also possible to rollback a transaction before it is committed:\n$connection-\u003erollback();\n```\n\nIf the query was an insertion of a new record, the insert ID can be retrieved\nby calling lastTransactionId:\n```php\n$connection-\u003elastTransactionId();\n```\n\n### Reading the result\n\nThe results of a query are send back to the application through an instance of\nthe `GrizzIt\\Dbal\\Pdo\\Component\\Result\\PdoQueryResult` class. It is possible to\niterate over this object by running it in a foreach loop. If all records should\nbe retrieved at once, then the `fetchAll()` method can be called on the result\nobject.\n\nThe amount of affected records can be retrieved by \"counting\" the object:\n```php\ncount($result); //Returns affected rows.\n```\n\nTo assert the success of the query, the `isSuccess` method can be called on the\nresult object.\n\nThe status code and errors (as a result of a failing query) can be retrieved by\ncalling `getErrors` and `getStatusCode` on the result object.\n\nAll SQLState status codes can be found [here](https://docs.oracle.com/cd/A84870_01/doc/appdev.816/a58231/appd.htm).\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## MIT License\n\nCopyright (c) GrizzIT\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrizz-it%2Fdbal-pdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrizz-it%2Fdbal-pdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrizz-it%2Fdbal-pdo/lists"}