Skip to content

A simple library for formatting the duplicate message in MySQL

Notifications You must be signed in to change notification settings

guilherme90/mysql-unique-message

Repository files navigation

MySQL Unique Message

A simple library for formatting the duplicate message in MySQL

  • PHP >= 7

Tests

$ composer test

PSR-2

$ composer cs
$ composer csfix

How to use

<?php

use \MySQLUniqueMessage\UniqueMessage;

// This message will return in your mysql using try / catch block
$message = 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry \'[email protected]\' for key \'email\'';
$output = UniqueMessage::format($message); 

Dump from $output

[
	'name' => 'email',
	'value' => '[email protected]',
	'message' => 'The email \'[email protected]\' is already registered.'
];

Enjoy!

About

A simple library for formatting the duplicate message in MySQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages