Completed
Push — master ( 20b587...a1178b )
by Rasmus
10s
created

SQLException::emulatedPrepare()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.2
cc 4
eloc 7
nc 5
nop 2
crap 4
1
<?php
2
3
namespace mindplay\sql\exceptions;
4
5
use Exception;
6
use mindplay\sql\framework\QueryFormatter;
7
use RuntimeException;
8
9
/**
10
 * This Exception-type represents an SQL error
11
 */
12
class SQLException extends RuntimeException
13
{
14
    /**
15
     * @param string         $sql    SQL statement (with ":name" placeholders)
16
     * @param array          $params map of parameter name/value pairs (to bind against placeholders in the statement)
17
     * @param string         $message
18
     * @param int            $code
19
     * @param Exception|null $previous
20
     */
21 1
    public function __construct($sql, $params = [], $message = 'SQL Error', $code = 0, Exception $previous = null)
22
    {
23 1
        parent::__construct(
24 1
            "{$message}\n" . QueryFormatter::formatQuery($sql, $params),
25
            $code,
26
            $previous
27
        );
28 1
    }
29
}
30