Skip to content

Detect primary/unique key or constraint violation errors from PDOException.

License

Notifications You must be signed in to change notification settings

mpyw/unique-violation-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unique Violation Detector Build Status Coverage Status

Detect primary/unique key or constraint violation errors from PDOException.

Installing

composer require mpyw/unique-violation-detector

Requirements

Package Version
PHP ^7.1 || ^8.0

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);

About

Detect primary/unique key or constraint violation errors from PDOException.

Resources

License

Stars

Watchers

Forks

Languages