PHPackages                             phpnomad/safemysql-integration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. phpnomad/safemysql-integration

ActiveLibrary[Database &amp; ORM](/categories/database)

phpnomad/safemysql-integration
==============================

SafeMySQL integration for PHPNomad database layer

1.0.2(3w ago)03.8k↓37.5%MITPHPPHP &gt;=8.2

Since Feb 7Pushed 3w agoCompare

[ Source](https://github.com/phpnomad/safemysql-integration)[ Packagist](https://packagist.org/packages/phpnomad/safemysql-integration)[ RSS](/packages/phpnomad-safemysql-integration/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (12)Versions (5)Used By (0)

phpnomad/safemysql-integration
==============================

[](#phpnomadsafemysql-integration)

[![Latest Version](https://camo.githubusercontent.com/3d507e662159ab6cb2a6452c8e7108d4089a8744e05c41829d90a5ebef884e83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f736166656d7973716c2d696e746567726174696f6e2e737667)](https://packagist.org/packages/phpnomad/safemysql-integration)[![Total Downloads](https://camo.githubusercontent.com/2870598a5b7aa575cd52f86d119d3f1f1b17d64d1b5716936192ba97b5b7506f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f736166656d7973716c2d696e746567726174696f6e2e737667)](https://packagist.org/packages/phpnomad/safemysql-integration)[![PHP Version](https://camo.githubusercontent.com/9f756207569120a9edaf9651d7851a08bd2ae8451d7fce5d56aea7519b00ccde/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f736166656d7973716c2d696e746567726174696f6e2e737667)](https://packagist.org/packages/phpnomad/safemysql-integration)[![License](https://camo.githubusercontent.com/2b73d55761036b5a5a2294d4ec805f43c2d7c06e4f821431d4e38c114988675e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f736166656d7973716c2d696e746567726174696f6e2e737667)](https://packagist.org/packages/phpnomad/safemysql-integration)

Integrates the [SafeMySQL](https://github.com/colshrapnel/safemysql) library with PHPNomad's database layer. Provides concrete strategies that plug a `SafeMySQL` instance into the abstractions declared by `phpnomad/mysql-integration` and `phpnomad/db`.

Installation
------------

[](#installation)

```
composer require phpnomad/safemysql-integration
```

What This Provides
------------------

[](#what-this-provides)

- `SafeMySqlDatabaseStrategy` implements `DatabaseStrategy` from `phpnomad/mysql-integration`. It uses SafeMySQL's placeholder syntax (`?s`, `?i`, `?a`, `?u`, `?n`, `?p`) for parameter substitution, with extra handling for row tuples and associative arrays so bulk inserts and updates format correctly.
- `SafeMySqlAtomicOperationStrategy` implements `AtomicOperationStrategy` from `phpnomad/db`. It wraps a callable in `START TRANSACTION` / `COMMIT` / `ROLLBACK`, rolling back and re-throwing on any `Throwable`.

Requirements
------------

[](#requirements)

- PHP 8.2+
- `phpnomad/mysql-integration`
- `phpnomad/db`
- `phpnomad/datastore`
- `colshrapnel/safemysql`

Usage
-----

[](#usage)

Create one `SafeMySQL` instance for the application and bind both strategies to it in your container. The strategies share the same connection so transaction state carries across queries run through the database strategy.

```
