change query to only explain selects

mysql doesn't let you explain non-selects
This commit is contained in:
R Odili 2015-12-22 01:56:05 -05:00
parent 499e609ec7
commit d5e11b8fd9

6
inc/database.php Normal file → Executable file
View File

@ -14,7 +14,8 @@ class PreparedQueryDebug {
$query = preg_replace("/[\n\t]+/", ' ', $query);
$this->query = $pdo->prepare($query);
if ($config['debug'] && $config['debug_explain'] && preg_match('/^(SELECT|INSERT|UPDATE|DELETE) /i', $query))
//|INSERT|UPDATE|DELETE
if ($config['debug'] && $config['debug_explain'] && preg_match('/^(SELECT) /i', $query))
$this->explain_query = $pdo->prepare("EXPLAIN $query");
}
public function __call($function, $args) {
@ -127,7 +128,8 @@ function query($query) {
sql_open();
if ($config['debug']) {
if ($config['debug_explain'] && preg_match('/^(SELECT|INSERT|UPDATE|DELETE) /i', $query)) {
//|INSERT|UPDATE|DELETE
if ($config['debug_explain'] && preg_match('/^(SELECT) /i', $query)) {
$explain = $pdo->query("EXPLAIN $query") or error(db_error());
}
$start = microtime(true);