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 \'user@provider.com\' for key \'email\'';
$output = UniqueMessage::format($message); 

Dump from $output

[
	'name' => 'email',
	'value' => 'user@provider.com',
	'message' => 'The email \'user@provider.com\' 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