PHP code example of mpyw / unique-violation-detector
1. Go to this page and download the library: Download mpyw/unique-violation-detector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mpyw / unique-violation-detector example snippets
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);