-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQLException.php
executable file
·59 lines (53 loc) · 1.36 KB
/
SQLException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php namespace App\Modules\SQLUtils\Exceptions;
class SQLException extends \Exception
{
/**
* The PDO Error Information array.
*
* Element Information
* 0 SQLSTATE error code (a five characters alphanumeric identifier defined in the ANSI SQL standard).
* 1 Driver specific error code.
* 2 Driver specific error message.
*
* @var array
*/
protected $errorInfo;
/**
* The data returned by the last query if there is any.
*
* @var mixed
*/
protected $data;
/**
* Constructor.
*
* @param array $errorInfo
* @param mixed $data
* @param int $code
* @param \Exception $previous
*/
public function __construct($errorInfo, $data = null, $code = 0, \Exception $previous = null)
{
$this->errorInfo = $errorInfo;
$this->data = $data;
parent::__construct('SQL exception occurred with message "' . $this->errorInfo[2] . '" and SQLState "' . $this->errorInfo[0] . '".', $code, $previous);
}
/**
* Get the error info array.
*
* @return array
*/
public function getErrorInfo()
{
return $this->errorInfo;
}
/**
* Get the data from the last query if any was returned.
*
* @return mixed
*/
public function getData()
{
return $this->data;
}
}