detect more complex case of SELECT DISTINCT for MySQL 3

This commit is contained in:
Marc Delisle
2004-10-15 19:38:23 +00:00
parent e151472dbd
commit fdad655074
2 changed files with 17 additions and 6 deletions

View File

@@ -11,6 +11,10 @@ $Source$
I find it faster this way, please tell me if you prefer
the old dialog method and why.
* tbl_change.php: bug #1038401, tabbing from value to value
* sql.php: detect this case:
SELECT DISTINCT x AS foo, y AS bar FROM sometable
and count rows correctly (in MySQL 3),
thanks to Matthias Pigulla (mp@webfactory.de)
2004-10-13 Michal Čihař <michal@cihar.com>
* libraries/fpdf/fpdf.php: Updated to 1.52.

19
sql.php
View File

@@ -437,13 +437,20 @@ else {
} else { // n o t " j u s t b r o w s i n g "
if (PMA_MYSQL_INT_VERSION < 40000) {
// TODO: detect DISTINCT in the parser
if (stristr($sql_query, 'DISTINCT')) {
$count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
} else {
$count_what = '*';
}
// detect this case:
// SELECT DISTINCT x AS foo, y AS bar FROM sometable
if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
$count_what = 'DISTINCT ';
$first_expr = TRUE;
foreach($analyzed_sql[0]['select_expr'] as $part) {
$count_what .= (!$first_expr ? ', ' : '') . $part['expr'];
$first_expr = FALSE;
}
} else {
$count_what = '*';
}
$count_query = 'SELECT COUNT(' . $count_what . ') AS count';
}