Completed
Push — namespace-model ( c67c40...018a87 )
by Sam
07:37
created

DatabaseException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
dl 0
loc 49
rs 10
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSQL() 0 3 1
A getParameters() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace SilverStripe\Model\Connect;
4
use Exception;
5
6
7
/**
8
 * Error class for database exceptions
9
 *
10
 * @package framework
11
 * @subpackage model
12
 */
13
class DatabaseException extends Exception {
14
15
	/**
16
	 * The SQL that generated this error
17
	 *
18
	 * @var string
19
	 */
20
	protected $sql = null;
21
22
	/**
23
	 * The parameters given for this query, if any
24
	 *
25
	 * @var array
26
	 */
27
	protected $parameters = array();
28
29
	/**
30
	 * Returns the SQL that generated this error
31
	 *
32
	 * @return string
33
	 */
34
	public function getSQL() {
35
		return $this->sql;
36
	}
37
38
	/**
39
	 * The parameters given for this query, if any
40
	 *
41
	 * @return array
42
	 */
43
	public function getParameters() {
44
		return $this->parameters;
45
	}
46
47
	/**
48
	 * Constructs the database exception
49
	 *
50
	 * @param string $message The Exception message to throw.
51
	 * @param integer $code The Exception code.
52
	 * @param Exception $previous The previous exception used for the exception chaining.
53
	 * @param string $sql The SQL executed for this query
54
	 * @param array $parameters The parameters given for this query, if any
55
	 */
56
	function __construct($message = '', $code = 0, $previous = null, $sql = null, $parameters = array()) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
		parent::__construct($message, $code, $previous);
58
		$this->sql = $sql;
59
		$this->parameters = $parameters;
60
	}
61
}
62