| @@ -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,44 +86,44 @@ | ||
| 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 | */ |
| @@ -143,12 +143,12 @@ | ||
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | return $data; |
| 146 | 146 | } |
| 147 | - | |
| 147 | + | |
| 148 | 148 | /** |
| 149 | 149 | * put your comment there... |
| 150 | - * | |
| 150 | + * | |
| 151 | 151 | * @param mixed $query |
| 152 | 152 | */ |
| 153 | 153 | public function exec($query) { |
| 154 | 154 | // Initialize! |
| @@ -158,24 +158,15 @@ | ||
| 158 | 158 | extract($this->onexec(compact('query', 'resultSet'))); |
| 159 | 159 | // filter can controller the returned value or customize the query! |
| 160 | 160 | if ($query && empty($result)) { |
| 161 | 161 | $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 | 162 | } |
| 170 | - | |
| 171 | - | |
| 172 | 163 | return $result; |
| 173 | 164 | } |
| 174 | - | |
| 165 | + | |
| 175 | 166 | /** |
| 176 | 167 | * put your comment there... |
| 177 | - * | |
| 168 | + * | |
| 178 | 169 | * @param mixed $table |
| 179 | 170 | */ |
| 180 | 171 | public function getColumns($table) { |
| 181 | 172 | $columns = array(); |
| @@ -188,17 +179,17 @@ | ||
| 188 | 179 | } |
| 189 | 180 | |
| 190 | 181 | /** |
| 191 | 182 | * put your comment there... |
| 192 | - * | |
| 183 | + * | |
| 193 | 184 | */ |
| 194 | 185 | public function getInsertId () { |
| 195 | - return $this->wpdb->insert_id; | |
| 186 | + return $this->wpdb->insert_id; | |
| 196 | 187 | } |
| 197 | - | |
| 188 | + | |
| 198 | 189 | /** |
| 199 | 190 | * put your comment there... |
| 200 | - * | |
| 191 | + * | |
| 201 | 192 | * @param mixed $query |
| 202 | 193 | * @param mixed $returnType |
| 203 | 194 | * @param mixed $default |
| 204 | 195 | */ |
| @@ -212,37 +203,37 @@ | ||
| 212 | 203 | return $row; |
| 213 | 204 | } |
| 214 | 205 | /** |
| 215 | 206 | * put your comment there... |
| 216 | - * | |
| 207 | + * | |
| 217 | 208 | */ |
| 218 | 209 | public function getTableName($table) { |
| 219 | 210 | return "{$this->wpdb->prefix}{$table}"; |
| 220 | 211 | } |
| 221 | - | |
| 212 | + | |
| 222 | 213 | /** |
| 223 | 214 | * put your comment there... |
| 224 | - * | |
| 215 | + * | |
| 225 | 216 | */ |
| 226 | 217 | public function getVar($query, $row = 0, $column = 0) { |
| 227 | 218 | return $this->wpdb->get_var($query, $row, $column); |
| 228 | 219 | } |
| 229 | - | |
| 220 | + | |
| 230 | 221 | /** |
| 231 | 222 | * put your comment there... |
| 232 | - * | |
| 223 | + * | |
| 233 | 224 | * @param mixed $query |
| 234 | 225 | */ |
| 235 | 226 | public function insert($query) { |
| 236 | 227 | return $this->addQueue($query); |
| 237 | 228 | } |
| 238 | - | |
| 229 | + | |
| 239 | 230 | /** |
| 240 | 231 | * Put your comments here... |
| 241 | 232 | * |
| 242 | 233 | * |
| 243 | - * @return | |
| 244 | - */ | |
| 234 | + * @return | |
| 235 | + */ | |
| 245 | 236 | public function merge($driver) { |
| 246 | 237 | // Put target driver queue at the end of our queue. |
| 247 | 238 | $this->queue = array_merge($this->queue, $driver->queue); |
| 248 | 239 | } |
| @@ -248,9 +239,9 @@ | ||
| 248 | 239 | } |
| 249 | 240 | |
| 250 | 241 | /** |
| 251 | 242 | * put your comment there... |
| 252 | - * | |
| 243 | + * | |
| 253 | 244 | * @param mixed $parameters |
| 254 | 245 | * @param mixed $operators |
| 255 | 246 | * @param mixed $defaultOperator |
| 256 | 247 | * @param mixed $excludeNulls |
| @@ -269,17 +260,17 @@ | ||
| 269 | 260 | $value = $this->escapeValue($value, $field); |
| 270 | 261 | // Get name-value operator. |
| 271 | 262 | $operator = isset($operators[$name]) ? $operators[$name] : $defaultOperator; |
| 272 | 263 | $prepared[] = "`{$name}`{$operator}{$value}"; |
| 273 | - } | |
| 264 | + } | |
| 274 | 265 | } |
| 275 | 266 | } |
| 276 | 267 | return $prepared; |
| 277 | 268 | } |
| 278 | - | |
| 269 | + | |
| 279 | 270 | /** |
| 280 | 271 | * put your comment there... |
| 281 | - * | |
| 272 | + * | |
| 282 | 273 | */ |
| 283 | 274 | public function processQueue() { |
| 284 | 275 | $queue = $this->onprocessqueue($this->queue); |
| 285 | 276 | // Collect queue commands. |
| @@ -290,12 +281,12 @@ | ||
| 290 | 281 | $this->clear(); |
| 291 | 282 | // Chain. |
| 292 | 283 | return $this; |
| 293 | 284 | } |
| 294 | - | |
| 285 | + | |
| 295 | 286 | /** |
| 296 | 287 | * put your comment there... |
| 297 | - * | |
| 288 | + * | |
| 298 | 289 | * @param mixed $query |
| 299 | 290 | */ |
| 300 | 291 | public function resolveTableName($query) { |
| 301 | 292 | // Define list of Prefixes to be replaced with Wordpress table prefix! |
| @@ -307,31 +298,31 @@ | ||
| 307 | 298 | } |
| 308 | 299 | // Return new query with table names resolved. |
| 309 | 300 | return $query; |
| 310 | 301 | } |
| 311 | - | |
| 302 | + | |
| 312 | 303 | /** |
| 313 | 304 | * Put your comments here... |
| 314 | 305 | * |
| 315 | 306 | * |
| 316 | - * @return | |
| 317 | - */ | |
| 307 | + * @return | |
| 308 | + */ | |
| 318 | 309 | public function rollback() { |
| 319 | 310 | $this->addQueue('ROLLBACK;'); |
| 320 | 311 | return $this; |
| 321 | 312 | } |
| 322 | - | |
| 313 | + | |
| 323 | 314 | /** |
| 324 | 315 | * put your comment there... |
| 325 | - * | |
| 316 | + * | |
| 326 | 317 | */ |
| 327 | 318 | public function row($query) { |
| 328 | 319 | return $this->wpdb->get_row($query); |
| 329 | 320 | } |
| 330 | - | |
| 321 | + | |
| 331 | 322 | /** |
| 332 | 323 | * put your comment there... |
| 333 | - * | |
| 324 | + * | |
| 334 | 325 | * @param mixed $query |
| 335 | 326 | */ |
| 336 | 327 | public function select($query, $returnType = OBJECT_K) { |
| 337 | 328 | // Initialize! |
| @@ -344,29 +335,29 @@ | ||
| 344 | 335 | $resultSet = $this->wpdb->get_results($query, $returnType); |
| 345 | 336 | } |
| 346 | 337 | return $resultSet; |
| 347 | 338 | } |
| 348 | - | |
| 339 | + | |
| 349 | 340 | /** |
| 350 | 341 | * Put your comments here... |
| 351 | 342 | * |
| 352 | 343 | * |
| 353 | - * @return | |
| 354 | - */ | |
| 344 | + * @return | |
| 345 | + */ | |
| 355 | 346 | public function startTransaction() { |
| 356 | 347 | $this->addQueue('BEGIN WORK;'); |
| 357 | 348 | return $this; |
| 358 | 349 | } |
| 359 | - | |
| 350 | + | |
| 360 | 351 | /** |
| 361 | 352 | * put your comment there... |
| 362 | - * | |
| 353 | + * | |
| 363 | 354 | * @param mixed $query |
| 364 | 355 | */ |
| 365 | 356 | public function update($query) { |
| 366 | 357 | return $this->addQueue($query); |
| 367 | 358 | } |
| 368 | - | |
| 359 | + | |
| 369 | 360 | } // End class. |
| 370 | 361 | |
| 371 | 362 | // Hooking! |
| 372 | 363 | CJTMYSQLQueueDriver::define('CJTMYSQLQueueDriver', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |