{"id":18761055,"url":"https://github.com/migliori/php-pdo-db-class","last_synced_at":"2025-07-04T01:04:57.676Z","repository":{"id":205743641,"uuid":"714928127","full_name":"migliori/php-pdo-db-class","owner":"migliori","description":"PHP PDO wrapper class","archived":false,"fork":false,"pushed_at":"2024-04-23T05:52:28.000Z","size":430,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-14T18:57:00.904Z","etag":null,"topics":["database","firebird","mysql","oci","pagination","pdo","pdo-mysql","php","postgresql"],"latest_commit_sha":null,"homepage":"https://www.phpformbuilder.pro/documentation/php-pdo-database-class.php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/migliori.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-06T06:11:06.000Z","updated_at":"2024-04-23T05:52:32.000Z","dependencies_parsed_at":"2024-04-12T08:13:29.512Z","dependency_job_id":"779b9270-427c-4039-9a8c-ab72fc7e9d11","html_url":"https://github.com/migliori/php-pdo-db-class","commit_stats":null,"previous_names":["migliori/php-pdo-db-class"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/migliori/php-pdo-db-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migliori%2Fphp-pdo-db-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migliori%2Fphp-pdo-db-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migliori%2Fphp-pdo-db-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migliori%2Fphp-pdo-db-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/migliori","download_url":"https://codeload.github.com/migliori/php-pdo-db-class/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migliori%2Fphp-pdo-db-class/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260492080,"owners_count":23017203,"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","firebird","mysql","oci","pagination","pdo","pdo-mysql","php","postgresql"],"created_at":"2024-11-07T18:14:50.564Z","updated_at":"2025-07-04T01:04:57.618Z","avatar_url":"https://github.com/migliori.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# [DEPRECATED] PHP PDO Database class\n\n![Static Badge](https://img.shields.io/badge/php%207.4+-fafafa?logo=php) [![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/)\n\n\u003e :warning: **DEPRECATION NOTICE**: This package is no longer maintained and has been deprecated. It's been replaced by [PowerLite PDO](https://www.powerlitepdo.com). Please visit the [PowerLite PDO GitHub repository](https://github.com/migliori/power-lite-pdo) for the latest updates and support.\n\nThis DB class provides a set of simple, intuitive methods for executing queries and retrieving data. It handles pagination, error handling and debugging.\n\nThe code is fully documented with PHPDOC. It provides types \u0026 type hinting and follows the highest coding standards (PHPSTAN Level 9).\n\n## Demo\n\n[PDO Database class - queries and pagination demos](https://www.phpformbuilder.pro/phpformbuilder/vendor/migliori/php-pdo-database-class/examples/select.php)\n\n## Features\n\n- Connection to any MySQL, Firebird, OCI (Oracle) or Pgsql (PostgreSQL) database\n- SQL queries Sending\n- Generation and sending of prepared PDO queries\n- Functions available for all types of queries:\n  - Select\n  - SelectCount\n  - SelectRow\n  - SelectValue\n  - Query\n  - QueryRow\n  - QueryValue\n  - Execute\n  - Insert\n  - Update\n  - Delete\n  - GetColums\n  - GetColumnsNames\n  - GetTables\n  - TransactionBegin\n  - TransactionCommit\n  - TransactionRollback\n- Pagination with configuration and options\n- Register your connection settings in a single safe place\n- DEBUG mode - display of SQL queries sent to the server and detailed information\n- Error event handling and PHP error logging with try/catch\n\n## Requirements\n\nPHP ^7.4, PHP 8.x\n\n## Documentation\n\n[PHP PDO Database class - Full detailed documentation, functions reference \u0026 code samples](https://www.phpformbuilder.pro/documentation/php-pdo-database-class.php)\n\n## Installation\n\nClone / download or install with Composer\n\n```bash\n  composer require migliori/php-pdo-database-class\n```\n\n## Usage/Examples\n\n1. Open `src/connect/db-connect.php` in your code editor and set the followings constants to connect to your database:\n\n    ```php\n    PDO_DRIVER // 'mysql', 'firebird', 'oci' or 'pgsql'\n    DB_HOST    // For instance 'localhost'\n    DB_NAME    // Your database name\n    DB_USER    // Your database username\n    DB_PASS    // Your database password\n    DB_PORT[OPTIONAL]    // The default port is 3306\n    ```\n\n2. Require `src/connect/db-connect.php` and you can connect to both your localhost and production server using `$db = new DB();` without any argument.\n\n    ```php\n    use Migliori\\Database\\Db;\n\n    // register the database connection settings\n    require_once 'src/connect/db-connect.php';\n\n    // Then connect to the database\n    $db = new DB();\n\n    // or connect and show all the encountered errors automatically\n    $db = new DB(true);\n\n    // or connect, then test the connection and retrieve the error if the database is not connected\n    $db = new DB();\n    if (!$db-\u003eisConnected()) {\n        $error_message = $db-\u003eerror();\n    }\n    ```\n\n3. Call the methods to send your queries and retrieve the results.\n\n    ```php\n    // Select rows without using SQL\n    $values = array('id', 'first_name', 'last_name');\n    $where = array('country' =\u003e 'Indonesia');\n    $db-\u003eselect('customers', $values, $where);\n\n    // We can make more complex where clauses in the Select, Update, and Delete methods\n    $values = array('id', 'first_name', 'last_name');\n    $where = array(\n        'zip_code IS NOT NULL',\n        'id \u003e' =\u003e 10,\n        'last_name LIKE' =\u003e '%Ge%'\n    );\n    $db-\u003eselect('customers', $values, $where);\n\n    // Let's sort by descending ID and run it in debug mode\n    $extras = array('order_by' =\u003e 'id DESC');\n    $db-\u003eselect('customers', $values, $where, $extras, true);\n\n\n    // loop through the results\n    while ($row = $db-\u003efetch()) {\n        echo $row-\u003efirst_name . ' ' . $row-\u003elast_name . '\u003cbr\u003e';\n    }\n\n    // or fetch all the records then loop\n    // (this function should not be used if a huge number of rows have been selected, otherwise it will consume a lot of memory)\n    $rows = $db-\u003efetchAll();\n\n    foreach ($rows as $row) {\n        echo $row-\u003efirst_name . ' ' . $row-\u003elast_name . '\u003cbr\u003e';\n    }\n    ```\n\nTo see all the public methods and more examples of use of use visit [https://www.phpformbuilder.pro/documentation/php-pdo-database-class.php](https://www.phpformbuilder.pro/documentation/php-pdo-database-class.php)\n\n## Example with Pagination\n\n1. Open `database/db-connect.php` in your code editor and set the followings constants to connect to your database:\n\n    ```php\n    PDO_DRIVER // 'mysql', 'firebird', 'oci' or 'pgsql'\n    DB_HOST    // For instance 'localhost'\n    DB_NAME    // Your database name\n    DB_USER    // Your database username\n    DB_PASS    // Your database password\n    DB_PORT[OPTIONAL]    // The default port is 3306\n    ```\n\n2. Get your records and the pagination HTML code\n\n    ```php\n    use Migliori\\Database\\Pagination;\n    use Migliori\\Database\\PdoSelectParams;\n\n    // register the database connection settings\n    require_once 'src/connect/db-connect.php';\n\n    // register the PDO parameters for the query in a PdoSelectParams() object\n    $values = array('id', 'first_name', 'last_name');\n    $where = array('country' =\u003e 'Indonesia');\n\n    $pdo_select_params = new PdoSelectParams('customers', $values, $where);\n\n    // create the Pagination object\n    $db = new Pagination($pdo_select_params);\n\n    // get the records and the pagination HTML code\n    $pagination_html = $db-\u003epagine();\n\n    // count the records and display them\n    $records_count = $db-\u003erowCount();\n\n    if (!empty($records_count)) {\n        while ($row = $db-\u003efetch()) {\n            echo $row-\u003efirst_name . ' ' . $row-\u003elast_name . ' : ' . $row-\u003ecountry . '\u003cbr\u003e';\n        }\n    }\n\n    echo $pagination_html;\n\n    ```\n\n## Running Tests\n\nTo run tests, run the following command\n\n```bash\nphp ./vendor/bin/phpunit test\n```\n\n## Contributing\n\nContributions are always welcome!\n\nPlease contact us for any improvement suggestions or send your pull requests\n\n## License\n\n[GNU General Public License v3.0](https://choosealicense.com/licenses/gpl-3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmigliori%2Fphp-pdo-db-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmigliori%2Fphp-pdo-db-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmigliori%2Fphp-pdo-db-class/lists"}