{"id":14972179,"url":"https://github.com/larapulse/database","last_synced_at":"2026-02-25T17:02:49.595Z","repository":{"id":57068385,"uuid":"105368476","full_name":"larapulse/database","owner":"larapulse","description":"PHP library and ORM to handle DB connection, apply C.R.U.D. operations","archived":false,"fork":false,"pushed_at":"2017-12-12T17:34:58.000Z","size":33,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T00:35:22.213Z","etag":null,"topics":["database","mysql","mysql-database","orm","orm-library","orm-php-framework","pdo","pdo-mysql","pdo-php","pdo-wrapper","postgres","postgresql"],"latest_commit_sha":null,"homepage":null,"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/larapulse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-30T12:29:46.000Z","updated_at":"2018-04-21T19:06:58.000Z","dependencies_parsed_at":"2022-08-24T10:20:34.697Z","dependency_job_id":null,"html_url":"https://github.com/larapulse/database","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/larapulse/database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larapulse%2Fdatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larapulse%2Fdatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larapulse%2Fdatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larapulse%2Fdatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larapulse","download_url":"https://codeload.github.com/larapulse/database/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larapulse%2Fdatabase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29831752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T15:41:19.027Z","status":"ssl_error","status_checked_at":"2026-02-25T15:40:47.150Z","response_time":61,"last_error":"SSL_read: 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","mysql-database","orm","orm-library","orm-php-framework","pdo","pdo-mysql","pdo-php","pdo-wrapper","postgres","postgresql"],"created_at":"2024-09-24T13:46:30.272Z","updated_at":"2026-02-25T17:02:49.556Z","avatar_url":"https://github.com/larapulse.png","language":"PHP","readme":"# Database\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n\u003c!-- [![Total Downloads][ico-downloads]][link-downloads] --\u003e\n\nPHP library and ORM to handle DB connection, apply C.R.U.D. operations.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require thephpleague/database\n```\n\n## Usage\n\n``` php\n$config = [\n    'host'      =\u003e 'localhost',\n    'port'      =\u003e 3306,\n    'database'  =\u003e 'master_db',\n    'username'  =\u003e 'root',\n    'password'  =\u003e '',\n];\n\n$connection = new League\\Database\\ConnectionManager('core', $config);\n```\n\n### `BulkSql` usage\n\nBulk SQL classes could be useful in scripts, when you need to insert big amount of records.\n\n**Example 1:**\n\n\u003cdetails\u003e\n    \u003csummary\u003e`BulkInsert` usage\u003c/summary\u003e\n    \n``` php\nuse League\\Database\\BulkSql\\BulkInsert;\n\n$db = $connection-\u003egetMasterConnection();\n\n$bulkInsert = new BulkInsert($db, 'users');\n$bulkInsert\n    -\u003esetItemsPerQuery(50)\n    -\u003euseIgnore()\n    -\u003edisableIndexes();\n\ntry {\n    $db-\u003ebeginTransaction();\n    \n    foreach ($users as $user) {\n        $bulkInsert-\u003eadd($user);\n    }\n    \n    $bulkInsert-\u003efinish();\n    $affectedCount = $bulkInsert-\u003egetAffectedCount();\n    \n    $db-\u003ecommit();\n} catch (\\PDOException $e) {\n    $db-\u003erollBack();\n}\n```\n\u003c/details\u003e\n\n**Example 2:**\n\n\u003cdetails\u003e\n    \u003csummary\u003e`BulkReplace` and `BulkDelete` usage (could be useful with feeds)\u003c/summary\u003e\n    \n``` php\nuse League\\Database\\BulkSql\\BulkReplace;\nuse League\\Database\\BulkSql\\BulkDelete;\n\n$db = $connection-\u003egetMasterConnection();\n\n$bulkReplace = new BulkReplace($db, 'offers');\n$bulkReplace-\u003esetItemsPerQuery(500);\n$bulkDelete = new BulkDelete($db, 'offers');\n$bulkDelete-\u003esetItemsPerQuery(1000);\n\ntry {\n    $db-\u003ebeginTransaction();\n    \n    foreach ($offers as $offer) {\n        $flag = $offer['deltaStatus'] ?? null;\n        \n        switch ($delta) {\n            case 'REMOVE':\n                $bulkDelete-\u003eadd(['id' =\u003e $data['id']]);\n                break;\n            case 'ADD':\n                $bulkReplace-\u003eadd($data);\n                break;\n            default:\n                $logger-\u003enotice(\"Unsupported delta flag \\\"{$flag}\\\"\";\n        }\n    }\n\n    $bulkReplace-\u003efinish();\n    $bulkDelete-\u003efinish();\n    \n    $db-\u003ecommit();\n    \n    $insertsCount = $bulkReplace-\u003egetInsertedCount();\n    $updatesCount = $bulkReplace-\u003egetReplacedCount();\n    $deletesCount = $bulkDelete-\u003egetAffectedCount();\n} catch (\\PDOException $e) {\n    $db-\u003erollBack();\n}\n```\n\u003c/details\u003e\n\n## Change log\n\nPlease see [CHANGELOG](docs/CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](docs/CONTRIBUTING.md) and [CODE_OF_CONDUCT](docs/CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email sergey.podgornyy@yahoo.de instead of using the issue tracker.\n\n## Credits\n\n- [Sergey Podgornyy][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/thephpleague/database.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/larapulse/database/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/larapulse/database.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/larapulse/database.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/thephpleague/database.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/thephpleague/database\n[link-travis]: https://travis-ci.org/larapulse/database\n[link-scrutinizer]: https://scrutinizer-ci.com/g/larapulse/database/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/larapulse/database\n[link-downloads]: https://packagist.org/packages/thephpleague/database\n[link-author]: https://github.com/SergeyPodgornyy\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarapulse%2Fdatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarapulse%2Fdatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarapulse%2Fdatabase/lists"}