mpyw / unique-violation-detector
Detect primary/unique key or constraint violation errors from PDOException.
Installs: 59 473
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- ext-pdo: *
Requires (Dev)
- phpunit/phpunit: >=11.0
This package is auto-updated.
Last update: 2025-03-05 03:31:05 UTC
README
Detect primary/unique key or constraint violation errors from PDOException
.
Installing
composer require mpyw/unique-violation-detector
Requirements
Package | Version |
---|---|
PHP | ^8.2 |
Note
Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.
Supported PDO Drivers
Database | Driver | Auto-Discoverable |
---|---|---|
MySQL | pdo_mysql |
✅ |
PostgreSQL | pdo_pgsql |
✅ |
SQLite | pdo_sqlite |
✅ |
SQLServer | pdo_sqlsrv |
✅ |
SQLServer | pdo_odbc |
|
SQLServer | pdo_dblib |
|
Oracle | pdo_oci |
✅ |
Usage
use Mpyw\UniqueViolationDetector\MySQLDetector; // Explicitly instantiate a detector $violated = (new MySQLDetector())->uniqueConstraintViolated($exception);
use Mpyw\UniqueViolationDetector\DetectorDiscoverer; // Discover a detector from a PDO instance // (Not available for pdo_odbc and pdo_dblib) $violated = (new DetectorDiscoverer()) ->discover($pdo) ->uniqueConstraintViolated($exception);