PluginProbe
CSS & JavaScript Toolbox / 7.2
CSS & JavaScript Toolbox v7.2
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/xtable.inc.php +77 -86 11.87.2 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,55 +6,55 @@
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
8 8
9 9 /**
10 -*
10 +*
11 11 */
12 12 abstract class CJTxTable extends CJTHookableClass {
13 -
13 +
14 14 /**
15 15 * put your comment there...
16 - *
16 + *
17 17 * @var mixed
18 18 */
19 19 protected $dbDriver;
20 -
20 +
21 21 /**
22 22 * put your comment there...
23 - *
23 + *
24 24 * @var mixed
25 25 */
26 26 private $fields;
27 -
27 +
28 28 /**
29 29 * put your comment there...
30 - *
30 + *
31 31 * @var mixed
32 32 */
33 33 protected $item;
34 -
34 +
35 35 /**
36 36 * put your comment there...
37 - *
37 + *
38 38 * @var mixed
39 39 */
40 40 protected $key;
41 -
41 +
42 42 /**
43 - *
43 + *
44 44 */
45 45 private $name;
46 -
46 +
47 47 /**
48 48 * put your comment there...
49 - *
49 + *
50 50 * @var mixed
51 51 */
52 52 protected $onconcatquery = array('parameters' => array('query'));
53 -
53 +
54 54 /**
55 55 * put your comment there...
56 - *
56 + *
57 57 * @var mixed
58 58 */
59 59 protected $ondelete = array('parameters' => array('query', 'key'));
60 60
@@ -59,9 +59,9 @@
59 59 protected $ondelete = array('parameters' => array('query', 'key'));
60 60
61 61 /**
62 62 * put your comment there...
63 - *
63 + *
64 64 * @var mixed
65 65 */
66 66 protected $ongetdata = array('parameters' => array('item'));
67 67
@@ -66,9 +66,9 @@
66 66 protected $ongetdata = array('parameters' => array('item'));
67 67
68 68 /**
69 69 * put your comment there...
70 - *
70 + *
71 71 * @var mixed
72 72 */
73 73 protected $ongetfield = array('parameters' => array('value', 'name'));
74 74
@@ -73,23 +73,23 @@
73 73 protected $ongetfield = array('parameters' => array('value', 'name'));
74 74
75 75 /**
76 76 * put your comment there...
77 - *
77 + *
78 78 * @var mixed
79 79 */
80 80 protected static $onimport = array('parameters' => array('type'));
81 -
81 +
82 82 /**
83 83 * put your comment there...
84 - *
84 + *
85 85 * @var mixed
86 86 */
87 87 protected static $oninstantiate = array('parameters' => array('args'));
88 -
88 +
89 89 /**
90 90 * put your comment there...
91 - *
91 + *
92 92 * @var mixed
93 93 */
94 94 protected $oninsert = array('parameters' => array('query'));
95 95
@@ -94,30 +94,30 @@
94 94 protected $oninsert = array('parameters' => array('query'));
95 95
96 96 /**
97 97 * put your comment there...
98 - *
98 + *
99 99 * @var mixed
100 100 */
101 101 protected $oninserted = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
102 -
102 +
103 103 /**
104 104 * put your comment there...
105 - *
105 + *
106 106 * @var mixed
107 107 */
108 108 protected $onloadquery = array('parameters' => array('query'));
109 -
109 +
110 110 /**
111 111 * put your comment there...
112 - *
112 + *
113 113 * @var mixed
114 114 */
115 115 protected $onsetfield = array('parameters' => array('property'));
116 -
116 +
117 117 /**
118 118 * put your comment there...
119 - *
119 + *
120 120 * @var mixed
121 121 */
122 122 protected $onupdate = array('parameters' => array('query'));
123 123
@@ -122,16 +122,16 @@
122 122 protected $onupdate = array('parameters' => array('query'));
123 123
124 124 /**
125 125 * put your comment there...
126 - *
126 + *
127 127 * @var mixed
128 128 */
129 129 protected $onupdated = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
130 -
130 +
131 131 /**
132 132 * put your comment there...
133 - *
133 + *
134 134 * @param mixed $table
135 135 * @return CJTxTable
136 136 */
137 137 public function __construct($dbDriver, $table, $key = array('id')) {
@@ -145,14 +145,14 @@
145 145 $this->key = $key;
146 146 // Read table fields.
147 147 $this->fields = $this->dbDriver->getColumns($this->table());
148 148 }
149 -
149 +
150 150 /**
151 151 * DELETE!
152 - *
152 + *
153 153 * THIS METHOD SUPPORT COMPOUND KEYS!
154 - *
154 + *
155 155 */
156 156 public function delete($key = null) {
157 157 // building DELETE query!
158 158 $query['from'] = "DELETE FROM {$this->table()}";
@@ -160,17 +160,17 @@
160 160 // filtering!
161 161 if ($query = $this->ondelete($query, $key)) {
162 162 $query = "{$query['from']} {$query['where']}";
163 163 // Delete record.
164 - $this->dbDriver->delete($query)->processQueue();
164 + $this->dbDriver->delete($query)->processQueue();
165 165 }
166 166 // Chaining!
167 167 return $this;
168 168 }
169 -
169 +
170 170 /**
171 171 * put your comment there...
172 - *
172 + *
173 173 */
174 174 public function fetchAll() {
175 175 // Get query.
176 176 $query = $this->getLoadQuery();
@@ -179,9 +179,9 @@
179 179 }
180 180
181 181 /**
182 182 * put your comment there...
183 - *
183 + *
184 184 * @param mixed $field
185 185 */
186 186 public function get($field) {
187 187 // Get the value of the field with E_ALL complain!
@@ -187,20 +187,20 @@
187 187 // Get the value of the field with E_ALL complain!
188 188 $value = (is_object($this->item) && property_exists($this->item, $field)) ? $this->item->{$field} : null;
189 189 return $this->ongetfield($value, $field);
190 190 }
191 -
191 +
192 192 /**
193 193 * put your comment there...
194 - *
194 + *
195 195 */
196 196 public function getData() {
197 197 return $this->ongetdata($this->item);
198 198 }
199 -
199 +
200 200 /**
201 201 * put your comment there...
202 - *
202 + *
203 203 * @param mixed $object
204 204 * @param mixed $dbDriver
205 205 * @return CJTxTable
206 206 */
@@ -219,12 +219,12 @@
219 219 $table->load($query);
220 220 }
221 221 return $table;
222 222 }
223 -
223 +
224 224 /**
225 225 * put your comment there...
226 - *
226 + *
227 227 * @param mixed $query
228 228 */
229 229 protected function getLoadQuery($query = null) {
230 230 $tableKey = null;
@@ -254,9 +254,9 @@
254 254 }
255 255
256 256 /**
257 257 * put your comment there...
258 - *
258 + *
259 259 * @param mixed $tableKey
260 260 */
261 261 public function getKey($tableKey = null) {
262 262 if (!$tableKey) {
@@ -264,20 +264,20 @@
264 264 }
265 265 $key = array_intersect_key(((array) $this->item), array_flip($tableKey));
266 266 return $key;
267 267 }
268 -
268 +
269 269 /**
270 270 * put your comment there...
271 - *
271 + *
272 272 */
273 273 public function getTableKey() {
274 - return $this->key;
274 + return $this->key;
275 275 }
276 -
276 +
277 277 /**
278 278 * put your comment there...
279 - *
279 + *
280 280 * @param mixed
281 281 */
282 282 public static function import($type) {
283 283 // Filtering parameters!
@@ -284,15 +284,15 @@
284 284 extract(self::trigger('CJTxTable.import', compact('type')));
285 285 // Implort table file.
286 286 cssJSToolbox::import("tables:{$type}.php");
287 287 }
288 -
288 +
289 289 /**
290 290 * put your comment there...
291 - *
291 + *
292 292 * @param mixed $tableKey
293 293 */
294 - public function isValidKey($tableKey = null) {
294 + public function isValidKey($tableKey = null) {
295 295 $isValid = false;
296 296 // Get key!
297 297 $key = $this->getKey($tableKey);
298 298 // If any field has a value then its not null key!
@@ -303,15 +303,15 @@
303 303 }
304 304 }
305 305 return $isValid;
306 306 }
307 +
307 308
308 309
309 -
310 310 /**
311 311 * Load record into table!
312 - *
313 - * @param mixed
312 + *
313 + * @param mixed
314 314 */
315 315 public function load($query = null) {
316 316 try {
317 317 // Get query to load!
@@ -325,23 +325,14 @@
325 325 }
326 326 // Chaining.
327 327 return $this;
328 328 }
329 -
329 +
330 330 /**
331 331 * put your comment there...
332 - *
333 - * @param mixed $values
334 - */
335 - public function loadAsKey($values) {
336 - return $this->setData($values)->load(array_keys($values));
337 - }
338 -
339 - /**
340 - * put your comment there...
341 - *
332 + *
342 333 * @todo Delete method and use CJTMYSQLQuery instead.
343 - *
334 + *
344 335 * @param mixed $parameters
345 336 */
346 337 protected function prepareQueryParameters($parameters, $operators = array(), $defaultOperator = '=', $excludeNulls = true) {
347 338 $prepared = array();
@@ -357,17 +348,17 @@
357 348 $value = $this->dbDriver->escapeValue($value, $field);
358 349 // Get name-value operator.
359 350 $operator = isset($operators[$name]) ? $operators[$name] : $defaultOperator;
360 351 $prepared[] = "`{$name}`{$operator}{$value}";
361 - }
352 + }
362 353 }
363 354 }
364 355 return $prepared;
365 356 }
366 -
357 +
367 358 /**
368 359 * THIS METHOD STILL DOESNT SUPPORT COMPOUND KEYS!!
369 - *
360 + *
370 361 * @param mixed $forceInsert
371 362 * @param mixed $updateIdField
372 363 * @return CJTxTable
373 364 */
@@ -382,9 +373,9 @@
382 373 $condition = implode(' AND ', $this->prepareQueryParameters($this->getKey()));
383 374 $query = "UPDATE {$this->table()} SET {$fieldsList} WHERE {$condition}";
384 375 if ($query = $this->onupdate($query)) {
385 376 $this->dbDriver->update($query)
386 - ->processQueue();
377 + ->processQueue();
387 378 $this->onupdated();
388 379 }
389 380 }
390 381 else { // Insert.
@@ -397,12 +388,12 @@
397 388 }
398 389 }
399 390 return $this;
400 391 }
401 -
392 +
402 393 /**
403 394 * put your comment there...
404 - *
395 + *
405 396 * @param mixed $prop
406 397 * @param mixed $value
407 398 */
408 399 public function set($prop, $value) {
@@ -409,12 +400,12 @@
409 400 extract($this->onsetfield(compact('prop', 'value')));
410 401 $this->item->{$prop} = $value;
411 402 return $this;
412 403 }
413 -
404 +
414 405 /**
415 406 * put your comment there...
416 - *
407 + *
417 408 * @param mixed $data
418 409 */
419 410 public function setData($data) {
420 411 // Cast to array.
@@ -429,9 +420,9 @@
429 420 }
430 421
431 422 /**
432 423 * put your comment there...
433 - *
424 + *
434 425 * @param mixed $item
435 426 * @return CJTxTable
436 427 */
437 428 public function setItem($item = null) {
@@ -441,29 +432,29 @@
441 432 }
442 433 // Set internal item object!
443 434 $this->item = $item;
444 435 // Chaining!
445 - return $this;
436 + return $this;
446 437 }
447 -
438 +
448 439 /**
449 440 * put your comment there...
450 - *
441 + *
451 442 * @param mixed $key
452 443 */
453 444 public function setTableKey($key) {
454 445 $this->key = $key;
455 - return $this;
446 + return $this;
456 447 }
457 -
448 +
458 449 /**
459 450 * put your comment there...
460 - *
451 + *
461 452 */
462 453 public function table() {
463 454 return $this->name;
464 455 }
465 -
456 +
466 457 } // End class.
467 458
468 459 // Hookable.
469 460 CJTxTable::define('CJTxTable', array('hookType' =>CJTWordpressEvents::HOOK_FILTER));