PluginProbe
CSS & JavaScript Toolbox / 7.1
CSS & JavaScript Toolbox v7.1
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | framework/db/mysql/queue-driver.inc.php +64 -78 117.1 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
@@ -6,15 +6,15 @@
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
8 8
9 9 /**
10 -*
10 +*
11 11 */
12 12 class CJTMYSQLQueueDriver extends CJTHookableClass {
13 -
13 +
14 14 /**
15 15 * put your comment there...
16 - *
16 + *
17 17 * @var mixed
18 18 */
19 19 protected $queue = array();
20 20
@@ -19,16 +19,16 @@
19 19 protected $queue = array();
20 20
21 21 /**
22 22 * put your comment there...
23 - *
23 + *
24 24 * @var mixed
25 25 */
26 26 protected $onexec = array('parameters' => array('param'));
27 -
27 +
28 28 /**
29 29 * put your comment there...
30 - *
30 + *
31 31 * @var mixed
32 32 */
33 33 protected $onprocessqueue = array('parameters' => array('queue'));
34 34
@@ -33,16 +33,16 @@
33 33 protected $onprocessqueue = array('parameters' => array('queue'));
34 34
35 35 /**
36 36 * put your comment there...
37 - *
37 + *
38 38 * @var mixed
39 39 */
40 40 protected $onprocesscommand = array('parameters' => array('command'));
41 -
41 +
42 42 /**
43 43 * put your comment there...
44 - *
44 + *
45 45 * @var mixed
46 46 */
47 47 protected $onqueue = array('parameters' => array('query'));
48 48
@@ -47,9 +47,9 @@
47 47 protected $onqueue = array('parameters' => array('query'));
48 48
49 49 /**
50 50 * put your comment there...
51 - *
51 + *
52 52 * @var mixed
53 53 */
54 54 protected $onqueuereturn = array('parameters' => array('driver'));
55 55
@@ -54,23 +54,23 @@
54 54 protected $onqueuereturn = array('parameters' => array('driver'));
55 55
56 56 /**
57 57 * put your comment there...
58 - *
58 + *
59 59 * @var mixed
60 60 */
61 61 protected $onselect = array('parameters' => array('param'));
62 -
62 +
63 63 /**
64 64 * put your comment there...
65 - *
65 + *
66 66 * @var mixed
67 67 */
68 68 private $wpdb = null;
69 -
69 +
70 70 /**
71 71 * put your comment there...
72 - *
72 + *
73 73 */
74 74 public function __construct($mysqlDriver) {
75 75 // Hookable!
76 76 parent::__construct();
@@ -76,12 +76,12 @@
76 76 parent::__construct();
77 77 // Internal DB engine!
78 78 $this->wpdb = $mysqlDriver;
79 79 }
80 -
80 +
81 81 /**
82 82 * put your comment there...
83 - *
83 + *
84 84 * @param mixed $query
85 85 */
86 86 protected function addQueue($query) {
87 87 $query = $this->resolveTableName($query);
@@ -86,54 +86,49 @@
86 86 protected function addQueue($query) {
87 87 $query = $this->resolveTableName($query);
88 88 $key = md5($query);
89 89 if ($query = $this->onqueue($query)) {
90 - $this->queue[$key] = $query;
90 + $this->queue[$key] = $query;
91 91 }
92 92 return $this->onqueuereturn($this);
93 93 }
94 -
94 +
95 95 /**
96 96 * put your comment there...
97 - *
97 + *
98 98 */
99 99 public function clear() {
100 100 $this->queue = array();
101 101 }
102 -
102 +
103 103 /**
104 104 * Put your comments here...
105 105 *
106 106 *
107 - * @return
108 - */
107 + * @return
108 + */
109 109 public function commit() {
110 110 $this->addQueue('COMMIT;');
111 111 return $this;
112 112 }
113 -
113 +
114 114 /**
115 115 * put your comment there...
116 - *
116 + *
117 117 * @param mixed $query
118 118 */
119 119 public function delete($query) {
120 120 return $this->addQueue($query);
121 121 }
122 -
122 +
123 123 /**
124 124 * put your comment there...
125 - *
125 + *
126 126 * @param string $data
127 127 * @param mixed $field
128 128 * @return string
129 129 */
130 130 public function escapeValue($data, $field) {
131 - # MYSQLI doesn't has numeric field.
132 - if ($this->wpdb->use_mysqli) {
133 - $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
134 - }
135 - # Check if numeric
136 131 switch ($field->numeric) {
137 132 case 0:
138 133 $data = esc_sql($data);
139 134 $data = "'{$data}'";
@@ -143,12 +138,12 @@
143 138 break;
144 139 }
145 140 return $data;
146 141 }
147 -
142 +
148 143 /**
149 144 * put your comment there...
150 - *
145 + *
151 146 * @param mixed $query
152 147 */
153 148 public function exec($query) {
154 149 // Initialize!
@@ -158,29 +153,20 @@
158 153 extract($this->onexec(compact('query', 'resultSet')));
159 154 // filter can controller the returned value or customize the query!
160 155 if ($query && empty($result)) {
161 156 $result = $this->wpdb->query($query);
162 -
163 - if ( strpos( $query, 'SHOW TABLES' ) !== false && ! $result ) {
164 - echo 'Some tables could not be created! Please contact support with the error';
165 - echo '<br><strong>' . str_replace( 'SHOW TABLES LIKE ', '', $query ) . '</strong>';
166 -
167 - wp_die();
168 - }
169 157 }
170 -
171 -
172 158 return $result;
173 159 }
174 -
160 +
175 161 /**
176 162 * put your comment there...
177 - *
163 + *
178 164 * @param mixed $table
179 165 */
180 166 public function getColumns($table) {
181 167 $columns = array();
182 - $this->select("SELECT * FROM {$table} WHERE 1!=1 LIMIT 0,1;");
168 + $this->select("SELECT * FROM {$table} WHERE 1!=1;");
183 169 // Use field name as element key.
184 170 foreach ($this->wpdb->col_info as $index => $column) {
185 171 $columns[$column->name] = $column;
186 172 }
@@ -188,17 +174,17 @@
188 174 }
189 175
190 176 /**
191 177 * put your comment there...
192 - *
178 + *
193 179 */
194 180 public function getInsertId () {
195 - return $this->wpdb->insert_id;
181 + return $this->wpdb->insert_id;
196 182 }
197 -
183 +
198 184 /**
199 185 * put your comment there...
200 - *
186 + *
201 187 * @param mixed $query
202 188 * @param mixed $returnType
203 189 * @param mixed $default
204 190 */
@@ -212,37 +198,37 @@
212 198 return $row;
213 199 }
214 200 /**
215 201 * put your comment there...
216 - *
202 + *
217 203 */
218 204 public function getTableName($table) {
219 205 return "{$this->wpdb->prefix}{$table}";
220 206 }
221 -
207 +
222 208 /**
223 209 * put your comment there...
224 - *
210 + *
225 211 */
226 212 public function getVar($query, $row = 0, $column = 0) {
227 213 return $this->wpdb->get_var($query, $row, $column);
228 214 }
229 -
215 +
230 216 /**
231 217 * put your comment there...
232 - *
218 + *
233 219 * @param mixed $query
234 220 */
235 221 public function insert($query) {
236 222 return $this->addQueue($query);
237 223 }
238 -
224 +
239 225 /**
240 226 * Put your comments here...
241 227 *
242 228 *
243 - * @return
244 - */
229 + * @return
230 + */
245 231 public function merge($driver) {
246 232 // Put target driver queue at the end of our queue.
247 233 $this->queue = array_merge($this->queue, $driver->queue);
248 234 }
@@ -248,9 +234,9 @@
248 234 }
249 235
250 236 /**
251 237 * put your comment there...
252 - *
238 + *
253 239 * @param mixed $parameters
254 240 * @param mixed $operators
255 241 * @param mixed $defaultOperator
256 242 * @param mixed $excludeNulls
@@ -269,17 +255,17 @@
269 255 $value = $this->escapeValue($value, $field);
270 256 // Get name-value operator.
271 257 $operator = isset($operators[$name]) ? $operators[$name] : $defaultOperator;
272 258 $prepared[] = "`{$name}`{$operator}{$value}";
273 - }
259 + }
274 260 }
275 261 }
276 262 return $prepared;
277 263 }
278 -
264 +
279 265 /**
280 266 * put your comment there...
281 - *
267 + *
282 268 */
283 269 public function processQueue() {
284 270 $queue = $this->onprocessqueue($this->queue);
285 271 // Collect queue commands.
@@ -290,12 +276,12 @@
290 276 $this->clear();
291 277 // Chain.
292 278 return $this;
293 279 }
294 -
280 +
295 281 /**
296 282 * put your comment there...
297 - *
283 + *
298 284 * @param mixed $query
299 285 */
300 286 public function resolveTableName($query) {
301 287 // Define list of Prefixes to be replaced with Wordpress table prefix!
@@ -307,31 +293,31 @@
307 293 }
308 294 // Return new query with table names resolved.
309 295 return $query;
310 296 }
311 -
297 +
312 298 /**
313 299 * Put your comments here...
314 300 *
315 301 *
316 - * @return
317 - */
302 + * @return
303 + */
318 304 public function rollback() {
319 305 $this->addQueue('ROLLBACK;');
320 306 return $this;
321 307 }
322 -
308 +
323 309 /**
324 310 * put your comment there...
325 - *
311 + *
326 312 */
327 313 public function row($query) {
328 314 return $this->wpdb->get_row($query);
329 315 }
330 -
316 +
331 317 /**
332 318 * put your comment there...
333 - *
319 + *
334 320 * @param mixed $query
335 321 */
336 322 public function select($query, $returnType = OBJECT_K) {
337 323 // Initialize!
@@ -344,29 +330,29 @@
344 330 $resultSet = $this->wpdb->get_results($query, $returnType);
345 331 }
346 332 return $resultSet;
347 333 }
348 -
334 +
349 335 /**
350 336 * Put your comments here...
351 337 *
352 338 *
353 - * @return
354 - */
339 + * @return
340 + */
355 341 public function startTransaction() {
356 342 $this->addQueue('BEGIN WORK;');
357 343 return $this;
358 344 }
359 -
345 +
360 346 /**
361 347 * put your comment there...
362 - *
348 + *
363 349 * @param mixed $query
364 350 */
365 351 public function update($query) {
366 352 return $this->addQueue($query);
367 353 }
368 -
354 +
369 355 } // End class.
370 356
371 357 // Hooking!
372 358 CJTMYSQLQueueDriver::define('CJTMYSQLQueueDriver', array('hookType' => CJTWordpressEvents::HOOK_FILTER));