Changeset 1959
- Timestamp:
- 06/14/10 14:56:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/libs/extensions/ezSQL/mysql/ez_sql_mysql.php
r1955 r1959 169 169 */ 170 170 171 function query($query = '' )171 function query($query = '', $add_siteid_to_query = TRUE) 172 172 { 173 173 … … 216 216 } 217 217 218 if (MULTI_SITE == 'true' ) { $query = $this->whereMultiSite($query); }218 if (MULTI_SITE == 'true' && $add_siteid_to_query) { $query = $this->whereMultiSite($query); } 219 219 220 220 // Perform the query via std mysql_query function.. … … 391 391 if (stripos($query, ' FROM ') !== false) { 392 392 $array = explode('FROM ',$query); 393 394 if (!isset($array[1])) { var_dump($array); } 395 $array2 = explode(' ', $array[1]); 396 $table = $array2[0]; 397 398 $array3 = explode('_', $table); 399 $tablename = $array3[1]; 400 401 $tablename = str_replace(',', '', $tablename); 402 403 if (array_key_exists($tablename, $siteidtables)) { 404 if (stripos($query, $table)) { 405 if (stripos($query, 'WHERE') !== false) { 406 $array = explode('WHERE ', $query); 407 $query = $array[0] . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . " AND " . $array[1]; 408 } else { 409 $array = $array = explode('FROM ' . $table ,$query); 410 $query = $array[0] . ' FROM ' . $table . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . $array[1]; 393 394 if ($array[0] != 'SHOW COLUMNS') { 395 396 if (!isset($array[1])) { var_dump($array); } 397 $array2 = explode(' ', $array[1]); 398 $table = $array2[0]; 399 400 $array3 = explode('_', $table); 401 $tablename = $array3[1]; 402 403 $tablename = str_replace(',', '', $tablename); 404 405 if (array_key_exists($tablename, $siteidtables)) { 406 if (stripos($query, $table)) { 407 if (stripos($query, 'WHERE') !== false) { 408 $array = explode('WHERE ', $query); 409 $query = $array[0] . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . " AND " . $array[1]; 410 } else { 411 $array = $array = explode('FROM ' . $table ,$query); 412 $query = $array[0] . ' FROM ' . $table . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . $array[1]; 413 } 414 415 $after = "<span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>"; 416 //print $after; 411 417 } 412 413 $after = "<span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";414 //print $after;415 418 } 416 } 419 } 417 420 } 418 421 … … 439 442 440 443 if (stripos($query, 'INSERT INTO ') !== false) { 441 //print "<br/>this is INSERT " . $before;442 $pattern = '/^INSERT INTO(.*?)\ (/';444 // print "<br/>this is INSERT " . $before; 445 $pattern = '/^INSERT INTO(.*?)\SET/'; 443 446 preg_match($pattern, $query, $matches); 444 445 if ($matches) { $tablename = trim($matches[1]); } 446 //print $tablename; 447 if ($matches) { $tablename = trim($matches[1]); } else { 448 $pattern = '/^INSERT INTO(.*?)\(/'; 449 preg_match($pattern, $query, $matches); 450 if ($matches) { $tablename = trim($matches[1]); } 451 } 452 453 // print $tablename; 447 454 $tablename = str_ireplace(DB_PREFIX, '', $tablename); 448 455 … … 522 529 523 530 //if ($after == 'no') { print $before; } 524 //print $after;531 //print $after; 525 532 return $query; 526 533 }
Note: See TracChangeset
for help on using the changeset viewer.