PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / libraries / framework / Exceptions / QueryException.php
kirki / libraries / framework / Exceptions Last commit date
AuthorizationException.php 2 weeks ago InvalidCastException.php 2 weeks ago InvalidMiddlewareException.php 2 weeks ago InvalidRoutActionException.php 2 weeks ago InvalidValidationRuleException.php 2 weeks ago MassAssignmentException.php 2 weeks ago ModelNotFoundException.php 2 weeks ago MultipleRecordsFoundException.php 2 weeks ago NotFoundException.php 2 weeks ago QueryException.php 2 weeks ago RecordNotFoundException.php 2 weeks ago UniqueConstraintViolationException.php 2 weeks ago ValidationException.php 2 weeks ago
QueryException.php
107 lines
1 <?php
2
3 /**
4 * Exception thrown when a query fails.
5 *
6 * @package Framework
7 * @subpackage Exceptions
8 * @since 1.0.0
9 */
10 namespace Kirki\Framework\Exceptions;
11
12 \defined('ABSPATH') || exit;
13 use Exception;
14 use Throwable;
15 class QueryException extends Exception
16 {
17 /**
18 * The sql.
19 *
20 * @var mixed
21 *
22 * @since 1.0.0
23 */
24 protected $sql;
25 /**
26 * The bindings.
27 *
28 * @var mixed
29 *
30 * @since 1.0.0
31 */
32 protected $bindings;
33 /**
34 * Create a new instance.
35 *
36 * @param mixed $sql The sql.
37 * @param array $bindings The bindings.
38 * @param Throwable $error The error.
39 *
40 * @return void
41 *
42 * @since 1.0.0
43 */
44 public function __construct($sql, array $bindings, Throwable $error)
45 {
46 $this->sql = $sql;
47 $this->bindings = $bindings;
48 $this->code = $error->getCode();
49 $this->message = $this->format_message($sql, $bindings, $error);
50 }
51 /**
52 * Format message.
53 *
54 * @param mixed $sql The sql.
55 * @param mixed $bindings The bindings.
56 * @param Throwable $error The error.
57 *
58 * @return void
59 *
60 * @since 1.0.0
61 */
62 protected function format_message($sql, $bindings, Throwable $error)
63 {
64 return $error->getMessage() . ' (Connection: MySQL, SQL: ' . $this->prepare($sql, $bindings) . ')';
65 }
66 /**
67 * Get the sql.
68 *
69 * @return mixed
70 *
71 * @since 1.0.0
72 */
73 public function get_sql()
74 {
75 return $this->sql;
76 }
77 /**
78 * Get the bindings.
79 *
80 * @return mixed
81 *
82 * @since 1.0.0
83 */
84 public function get_bindings()
85 {
86 return $this->bindings;
87 }
88 /**
89 * Prepare.
90 *
91 * @param mixed $sql The sql.
92 * @param mixed $bindings The bindings.
93 *
94 * @return void
95 *
96 * @since 1.0.0
97 */
98 protected function prepare($sql, $bindings)
99 {
100 $count = 1;
101 foreach ($bindings as $binding) {
102 $sql = \str_replace('?', $binding, $sql, $count);
103 }
104 return $sql;
105 }
106 }
107