PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.0.1
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.0.1
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Database / DbInfo.php
wp-staging / Framework / Database Last commit date
QueryBuilder 4 years ago DbInfo.php 3 years ago ExcludedTables.php 4 years ago SearchReplace.php 3 years ago SelectedTables.php 2 years ago TableDto.php 5 years ago TableService.php 3 years ago TablesRenamer.php 2 years ago WpDbInfo.php 5 years ago iDbInfo.php 5 years ago
DbInfo.php
96 lines
1 <?php
2
3 namespace WPStaging\Framework\Database;
4
5 class DbInfo extends WpDbInfo
6 {
7 /*
8 * @var string
9 */
10 protected $server;
11
12 /*
13 * @var string
14 */
15 protected $user;
16
17 /*
18 * @var string
19 */
20 protected $password;
21
22 /*
23 * @var string
24 */
25 protected $database;
26
27 /*
28 * @var string|null
29 */
30 protected $error;
31
32 /*
33 * @var bool
34 */
35 protected $connected;
36
37 /*
38 * @var bool
39 */
40 protected $useSsl;
41
42 /*
43 * @param string $hostServer
44 * @param string $user
45 * @param string $password
46 * @param string $database
47 * @param bool $useSsl
48 */
49 public function __construct($hostServer, $user, $password, $database, $useSsl = false)
50 {
51 $this->server = $hostServer;
52 $this->user = $user;
53 $this->password = $password;
54 $this->database = $database;
55 $this->useSsl = $useSsl;
56
57 parent::__construct($this->connect());
58 }
59
60 public function connect()
61 {
62 if ($this->useSsl) {
63 // wpdb requires this constant for SSL use
64 if (!defined('MYSQL_CLIENT_FLAGS')) {
65 // phpcs:disable PHPCompatibility.Constants.NewConstants.mysqli_client_ssl_dont_verify_server_certFound
66 define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
67 }
68
69 $db = mysqli_init();
70 $db->real_connect($this->server, $this->user, $this->password, $this->database, null, null, MYSQL_CLIENT_FLAGS);
71 } else {
72 $db = new \mysqli($this->server, $this->user, $this->password, $this->database);
73 }
74
75 $this->error = null;
76 $this->connected = true;
77 if ($db->connect_error) {
78 $this->error = 'Connect Error (' . $db->connect_errno . ') ' . $db->connect_error;
79 $this->connected = false;
80 return;
81 }
82 $db->close();
83
84 $wpdb = new \wpdb($this->user, $this->password, $this->database, $this->server);
85 return $wpdb;
86 }
87
88 /*
89 * @return string|null
90 */
91 public function getError()
92 {
93 return $this->error;
94 }
95 }
96