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 +20 -5 5.72trunk 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;");
@@ -219,9 +234,9 @@
219 234 global $wpdb;
220 235 $table = $this->getBVTable($name);
221 236 return $wpdb->insert($table, $value);
222 237 }
223 -
238 +
224 239 public function tinfo($name) {
225 240 $result = array();
226 241 $table = $this->getBVTable($name);
227 242