Skip to content

Commit 8967ec6

Browse files
committed
fixed bug in limit clauses detection on some queries
1 parent f25809a commit 8967ec6

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

lib/util.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,12 @@ function createInfoGrid(&$db, $query="", $numQueries=1, $affectedRows=-1, $addHi
411411

412412
function getQueryType($query) {
413413
$type = array('result'=>FALSE,'can_limit'=>FALSE,'has_limit'=>FALSE,'update'=>FALSE);
414-
$query = trim($query, " \n\t");
415-
$query = strtolower(substr($query, 0, 7)); // work on only first few required characters of query
416-
if(substr($query, 0, 6) == "select" || substr($query, 0, 4) == "desc"
417-
|| substr($query, 0, 7) == "explain" || substr($query, 0, 4) == "show"
418-
|| substr($query, 0, 4) == "help" ) {
414+
$q = trim($query, " \n\t");
415+
$q = strtolower(substr($query, 0, 7)); // work on only first few required characters of query
416+
if( $q == "explain" || substr($q, 0, 6) == "select" || substr($q, 0, 4) == "desc"
417+
|| substr($q, 0, 4) == "show" || substr($q, 0, 4) == "help" ) {
419418
$type['result'] = TRUE;
420-
if (substr($query, 0, 6) == "select") {
419+
if (substr($q, 0, 6) == "select") {
421420
$type['can_limit'] = TRUE; // we don't want to limit results for other queries like 'show...'
422421
preg_match(LIMIT_REGEXP, $query, $matches);
423422
if (count($matches) == 3) {

0 commit comments

Comments
 (0)