PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.0.1
Booking for Appointments and Events Calendar – Amelia v2.0.1
2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / DB / WPDB / Connection.php
ameliabooking / src / Infrastructure / DB / WPDB Last commit date
Connection.php 6 months ago Statement.php 6 months ago
Connection.php
95 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\DB\WPDB;
4
5 use AmeliaBooking\Domain\Services\Database\ConnectionInterface;
6 use wpdb;
7
8 /**
9 * Class Connection
10 *
11 * @package AmeliaBooking\Infrastructure\DB\WPDB
12 * @property \wpdb $wpdb
13 */
14 class Connection implements ConnectionInterface
15 {
16 /** @var wpdb */
17 private $wpdb;
18
19 /**
20 * Connection constructor.
21 *
22 * @param wpdb $wpdb
23 */
24 public function __construct($wpdb)
25 {
26 $this->wpdb = $wpdb;
27 }
28
29 /**
30 * @param string $statement
31 *
32 * @return Statement
33 */
34 public function query($statement)
35 {
36 $stmt = new Statement($this->wpdb, $statement);
37 $stmt->execute();
38
39 return $stmt;
40 }
41
42 /**
43 * @param string $statement
44 *
45 * @return Statement
46 */
47 public function prepare($statement)
48 {
49 return new Statement($this->wpdb, $statement);
50 }
51
52 /**
53 * @return int
54 */
55 public function lastInsertId()
56 {
57 return $this->wpdb->insert_id;
58 }
59
60 /**
61 * @return void
62 */
63 public function beginTransaction()
64 {
65 $this->wpdb->query('START TRANSACTION');
66 }
67
68 /**
69 * @return void
70 */
71 public function commit()
72 {
73 $this->wpdb->query('COMMIT');
74 }
75
76 /**
77 * @return void
78 */
79 public function rollBack()
80 {
81 $this->wpdb->query('ROLLBACK');
82 }
83
84 /**
85 * Allow the connection wrapper to be used as a callable (historical usage in repositories `$connection()`).
86 * Returning $this preserves backward compatibility without altering repository constructors.
87 *
88 * @return $this
89 */
90 public function __invoke()
91 {
92 return $this;
93 }
94 }
95