forked from GithubBackups/vichan
change query to only explain selects
mysql doesn't let you explain non-selects
This commit is contained in:
parent
499e609ec7
commit
d5e11b8fd9
6
inc/database.php
Normal file → Executable file
6
inc/database.php
Normal file → Executable 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user