{"id":31943716,"url":"https://github.com/nstwfdev/mysql-connection","last_synced_at":"2025-10-14T10:00:14.446Z","repository":{"id":64996861,"uuid":"578546473","full_name":"nstwfdev/mysql-connection","owner":"nstwfdev","description":"ReactPHP MySQL transactional connection","archived":false,"fork":false,"pushed_at":"2025-08-12T15:08:54.000Z","size":111,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-12T22:05:38.394Z","etag":null,"topics":["connection","mysql","reactphp","transaction"],"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/nstwfdev.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}},"created_at":"2022-12-15T10:08:35.000Z","updated_at":"2025-07-11T20:17:56.000Z","dependencies_parsed_at":"2024-11-19T01:43:54.615Z","dependency_job_id":null,"html_url":"https://github.com/nstwfdev/mysql-connection","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.125,"last_synced_commit":"ca6e4119e43f465199f3386a41b7a4c5fb7054fc"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/nstwfdev/mysql-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstwfdev%2Fmysql-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstwfdev%2Fmysql-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstwfdev%2Fmysql-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstwfdev%2Fmysql-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nstwfdev","download_url":"https://codeload.github.com/nstwfdev/mysql-connection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstwfdev%2Fmysql-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018563,"owners_count":26086405,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["connection","mysql","reactphp","transaction"],"created_at":"2025-10-14T10:00:10.219Z","updated_at":"2025-10-14T10:00:14.430Z","avatar_url":"https://github.com/nstwfdev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reactphp MySQL transactional connection\n\n[![CI](https://img.shields.io/github/actions/workflow/status/nstwfdev/mysql-connection/ci.yml?branch=master\u0026label=ci\u0026logo=github)](https://github.com/nstwfdev/mysql-connection/actions?query=workflow%3Aci+branch%3Amaster)\n[![codecov](https://codecov.io/gh/nstwfdev/mysql-connection/branch/master/graph/badge.svg?token=9YL9FSM4RV)](https://codecov.io/gh/nstwfdev/mysql-connection)\n[![Packagist Version](https://img.shields.io/packagist/v/nstwf/mysql-connection?logo=packagist)](https://packagist.org/packages/nstwf/mysql-connection)\n\nSimple wrapper of [`ConnectionInterface`](https://github.com/friends-of-reactphp/mysql) that allows you to make transactions easier\n\n\u003e Read [main documentation](https://github.com/friends-of-reactphp/mysql) before\n\n**Table of contents**\n\n* [Quickstart example](#quickstart-example)\n* [Usage](#usage)\n    * [Factory](#factory)\n        * [createConnection()](#createConnection)\n    * [ConnectionInterface](#connectioninterface)\n        * [query()](#query)\n        * [transaction()](#transaction)\n        * [begin()](#begin)\n        * [commit()](#commit)\n        * [rollback()](#rollback)\n        * [ping()](#ping)\n        * [quit()](#quit)\n        * [close()](#close)\n* [Install](#install)\n* [Tests](#tests)\n* [License](#license)\n\n## Quickstart example\n\n```php\n$factory = new \\Nstwf\\MysqlConnection\\Factory\\ConnectionFactory(new \\React\\MySQL\\Factory());\n$connection = $factory-\u003ecreateConnection('localhost:3306');\n\n$connection\n    -\u003etransaction(function (\\Nstwf\\MysqlConnection\\ConnectionInterface $connection) {\n        return $connection-\u003equery('update users set name = \"Tim\" where id = 3');\n    })\n    -\u003ethen(function () {\n        echo 'OK';\n    }, function (\\Throwable $throwable) {\n        echo $throwable-\u003egetMessage();\n    });\n\n$connection-\u003equit();\n```\n\n## Usage\n\n### Factory\n\nThe main role of factory - creating `ConnectionInterface`, by wrapping [`Factory`](https://github.com/friends-of-reactphp/mysql#factory)\n\n#### createConnection\n\nCreate connection using [lazy connection](https://github.com/friends-of-reactphp/mysql#createlazyconnection) for future operations.\n\n```php\n$factory = new \\Nstwf\\MysqlConnection\\Factory\\ConnectionFactory(new \\React\\MySQL\\Factory());\n$connection = $factory-\u003ecreateConnection('localhost:3306');\n```\n\n### ConnectionInterface\n\nThat's a wrapper of original `ConnectionInterface`.\n\n\u003e Currently main difference - wrapper does not support event emitter methods\n\n[See original documentation](https://github.com/friends-of-reactphp/mysql#connectioninterface)\n\n#### query\n\n[See original documentation](https://github.com/friends-of-reactphp/mysql#query)\n\n#### transaction\n\nThe `transaction(callable $callable): PromiseInterface` method can be used to perform a transaction.\n\n```php\n$connection\n    -\u003etransaction(function (\\Nstwf\\MysqlConnection\\ConnectionInterface $connection) {\n        return $connection-\u003equery('update users set name = \"Tim\" where id = 3');\n    })\n    -\u003ethen(function () {\n        echo 'OK';\n    }, function (\\Throwable $throwable) {\n        echo $throwable-\u003egetMessage();\n    });\n```\n\nEquals to:\n\n```php\n$connection\n    -\u003equery(\"BEGIN\")\n    -\u003ethen(\n        fn() =\u003e $connection-\u003equery(\"COMMIT\"),\n        function (\\Throwable $throwable) use ($connection)  {\n        return $connection-\u003equery(\"ROLLBACK\")\n                          -\u003ethen(fn() =\u003e $throwable);\n        }\n    );\n```\n\n#### begin\n\nThe `begin(): PromiseInterface` method can be used to begin the transaction.\n\n```php\n$connection\n    -\u003ebegin()\n    -\u003ethen(function () {\n        echo 'Begin';\n    }, function (\\Throwable $throwable) {\n        echo $throwable-\u003egetMessage();\n    });\n```\n\nEquals to:\n\n\u003e Sql case-insensitive\n\n```php\n$connection-\u003equery(\"BEGIN\");\n// or\n$connection-\u003equery(\"START TRANSACTION\");\n```\n\n#### commit\n\nThe `commit(): PromiseInterface` method can be used to commit the transaction.\n\n```php\n$connection\n    -\u003ecommit()\n    -\u003ethen(function () use ($connection) {\n        echo 'Commit';\n    }, function (\\Throwable $throwable) {\n        echo $throwable-\u003egetMessage();\n    });\n```\n\nEquals to:\n\n\u003e sql case-insensitive\n\n```php\n$connection-\u003equery(\"COMMIT\");\n```\n\n#### rollback\n\nThe `rollback(): PromiseInterface` method can be used to rollback the transaction.\n\n```php\n$connection\n    -\u003erollback()\n    -\u003ethen(function () use ($connection) {\n        echo 'Rollback';\n    }, function (\\Throwable $throwable) {\n        echo $throwable-\u003egetMessage();\n    });\n```\n\nEquals to:\n\n\u003e Sql case-insensitive\n\n```php\n$connection-\u003equery(\"ROLLBACK\");\n```\n\n#### ping\n\n[See original documentation](https://github.com/friends-of-reactphp/mysql#ping)\n\n#### close\n\n[See original documentation](https://github.com/friends-of-reactphp/mysql#close)\n\n#### quit\n\n[See original documentation](https://github.com/friends-of-reactphp/mysql#quit)\n\n## Install\n\nThe recommended way to install this library is [through Composer](https://getcomposer.org).\n[New to Composer?](https://getcomposer.org/doc/00-intro.md)\n\nThis project follows [SemVer](https://semver.org/).\nThis will install the latest supported version:\n\n```bash\ncomposer require nstwf/mysql-connection\n```\n\nSee also the [CHANGELOG](docs/CHANGELOG.md) for details about version upgrades.\n\nIt's *highly recommended to use PHP 8+* * for this project.\n\n## Tests\n\nTo run the test suite, you first need to clone this repo and then install all\ndependencies [through Composer](https://getcomposer.org):\n\n```bash\ncomposer install\n```\n\nTo run the test suite, go to the project root and run:\n\n```bash\nvendor/bin/phpunit\n```\n\n## License\n\nMIT, see [LICENSE file](LICENSE).\n\n- [friends-of-reactphp/mysql](https://github.com/friends-of-reactphp/mysql) - main project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstwfdev%2Fmysql-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnstwfdev%2Fmysql-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstwfdev%2Fmysql-connection/lists"}