PluginProbe
CSS & JavaScript Toolbox / 8.2
CSS & JavaScript Toolbox v8.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 +78 -78 11.58.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,12 +325,12 @@
325 325 }
326 326 // Chaining.
327 327 return $this;
328 328 }
329 -
329 +
330 330 /**
331 331 * put your comment there...
332 - *
332 + *
333 333 * @param mixed $values
334 334 */
335 335 public function loadAsKey($values) {
336 336 return $this->setData($values)->load(array_keys($values));
@@ -337,11 +337,11 @@
337 337 }
338 338
339 339 /**
340 340 * put your comment there...
341 - *
341 + *
342 342 * @todo Delete method and use CJTMYSQLQuery instead.
343 - *
343 + *
344 344 * @param mixed $parameters
345 345 */
346 346 protected function prepareQueryParameters($parameters, $operators = array(), $defaultOperator = '=', $excludeNulls = true) {
347 347 $prepared = array();
@@ -357,17 +357,17 @@
357 357 $value = $this->dbDriver->escapeValue($value, $field);
358 358 // Get name-value operator.
359 359 $operator = isset($operators[$name]) ? $operators[$name] : $defaultOperator;
360 360 $prepared[] = "`{$name}`{$operator}{$value}";
361 - }
361 + }
362 362 }
363 363 }
364 364 return $prepared;
365 365 }
366 -
366 +
367 367 /**
368 368 * THIS METHOD STILL DOESNT SUPPORT COMPOUND KEYS!!
369 - *
369 + *
370 370 * @param mixed $forceInsert
371 371 * @param mixed $updateIdField
372 372 * @return CJTxTable
373 373 */
@@ -382,9 +382,9 @@
382 382 $condition = implode(' AND ', $this->prepareQueryParameters($this->getKey()));
383 383 $query = "UPDATE {$this->table()} SET {$fieldsList} WHERE {$condition}";
384 384 if ($query = $this->onupdate($query)) {
385 385 $this->dbDriver->update($query)
386 - ->processQueue();
386 + ->processQueue();
387 387 $this->onupdated();
388 388 }
389 389 }
390 390 else { // Insert.
@@ -397,12 +397,12 @@
397 397 }
398 398 }
399 399 return $this;
400 400 }
401 -
401 +
402 402 /**
403 403 * put your comment there...
404 - *
404 + *
405 405 * @param mixed $prop
406 406 * @param mixed $value
407 407 */
408 408 public function set($prop, $value) {
@@ -409,12 +409,12 @@
409 409 extract($this->onsetfield(compact('prop', 'value')));
410 410 $this->item->{$prop} = $value;
411 411 return $this;
412 412 }
413 -
413 +
414 414 /**
415 415 * put your comment there...
416 - *
416 + *
417 417 * @param mixed $data
418 418 */
419 419 public function setData($data) {
420 420 // Cast to array.
@@ -429,9 +429,9 @@
429 429 }
430 430
431 431 /**
432 432 * put your comment there...
433 - *
433 + *
434 434 * @param mixed $item
435 435 * @return CJTxTable
436 436 */
437 437 public function setItem($item = null) {
@@ -441,29 +441,29 @@
441 441 }
442 442 // Set internal item object!
443 443 $this->item = $item;
444 444 // Chaining!
445 - return $this;
445 + return $this;
446 446 }
447 -
447 +
448 448 /**
449 449 * put your comment there...
450 - *
450 + *
451 451 * @param mixed $key
452 452 */
453 453 public function setTableKey($key) {
454 454 $this->key = $key;
455 - return $this;
455 + return $this;
456 456 }
457 -
457 +
458 458 /**
459 459 * put your comment there...
460 - *
460 + *
461 461 */
462 462 public function table() {
463 463 return $this->name;
464 464 }
465 -
465 +
466 466 } // End class.
467 467
468 468 // Hookable.
469 469 CJTxTable::define('CJTxTable', array('hookType' =>CJTWordpressEvents::HOOK_FILTER));