PluginProbe
The WP Remote WordPress Plugin / trunk
The WP Remote WordPress Plugin vtrunk
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | wp_db.php +26 -5 5.45trunk View file →
@@ -1,6 +1,6 @@
1 1 <?php
2 -
2 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
3 3 if (!defined('ABSPATH')) exit;
4 4 if (!class_exists('WPRWPDb')) :
5 5
6 6 class WPRWPDb {
@@ -39,8 +39,23 @@
39 39 global $wpdb;
40 40 return $wpdb->get_col($query, $col);
41 41 }
42 42
43 + public function getLastRowId($col_name, $table_name) {
44 + $query = "SELECT MAX($col_name) AS last_id FROM $table_name";
45 + $results = $this->getResult($query);
46 + if (empty($results) || !is_array($results) || !is_array($results[0]) ||
47 + !array_key_exists("last_id", $results[0])) {
48 + return null;
49 + }
50 + $last_id = $results[0]['last_id'];
51 + if ($last_id === null) {
52 + return 0;
53 + } else if (is_numeric($last_id) === true) {
54 + return (int) $last_id;
55 + }
56 + }
57 +
43 58 public function tableName($table) {
44 59 return $table[0];
45 60 }
46 61
@@ -69,9 +84,9 @@
69 84
70 85 public function describeTable($table) {
71 86 return $this->getResult("DESCRIBE $table;");
72 87 }
73 -
88 +
74 89 public function showTableIndex($table) {
75 90 return $this->getResult("SHOW INDEX FROM $table");
76 91 }
77 92
@@ -96,9 +111,9 @@
96 111 $table = $this->getBVTable($name);
97 112 if (!$this->isTablePresent($table)) {
98 113 if ($usedbdelta) {
99 114 if (!function_exists('dbDelta'))
100 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115 + require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
101 116 dbDelta($query);
102 117 } else {
103 118 $this->query($query);
104 119 }
@@ -165,9 +180,9 @@
165 180 } else {
166 181 return false;
167 182 }
168 183 }
169 -
184 +
170 185 public function deleteBVTableContent($name, $filter = "") {
171 186 $table = $this->getBVTable($name);
172 187 if ($this->isTablePresent($table)) {
173 188 return $this->query("DELETE FROM $table $filter;");
@@ -213,9 +228,15 @@
213 228 global $wpdb;
214 229 $table = $this->getBVTable($name);
215 230 return $wpdb->replace($table, $value);
216 231 }
217 -
232 +
233 + public function insertIntoBVTable($name, $value) {
234 + global $wpdb;
235 + $table = $this->getBVTable($name);
236 + return $wpdb->insert($table, $value);
237 + }
238 +
218 239 public function tinfo($name) {
219 240 $result = array();
220 241 $table = $this->getBVTable($name);
221 242