'(SELECT ' . PMA_convert_using('`User`') . ' AS `User`, '
. PMA_convert_using('`Host`') . ' AS `Host`, '
. PMA_convert_using('`Db`') . ' AS `Db`, '
. $list_of_privileges
.' FROM `mysql`.`db`'
.' WHERE ' . PMA_convert_using(PMA_sqlAddslashes($checkprivs), 'quoted')
.' LIKE ' . PMA_convert_using('`Db`')
.' AND NOT (' . $list_of_compared_privileges. ')) '
.'UNION '
.'(SELECT ' . PMA_convert_using('`User`') . ' AS `User`, '
. PMA_convert_using('`Host`') . ' AS `Host`, '
. PMA_convert_using('*', 'quoted') .' AS `Db`, '
. $list_of_privileges
.' FROM `mysql`.`user` '
.' WHERE NOT (' . $list_of_compared_privileges . ')) '
.' ORDER BY `User` ASC,'
.' `Host` ASC,'
.' `Db` ASC;';
$res = PMA_DBI_query($sql_query);
$row = PMA_DBI_fetch_assoc($res);
if ($row) {
$found = TRUE;
}
} else {
// With MySQL 3, we need 2 seperate queries here.
$sql_query = 'SELECT * FROM `mysql`.`user` WHERE NOT (`Select_priv` = \'N\' AND `Insert_priv` = \'N\' AND `Update_priv` = \'N\' AND `Delete_priv` = \'N\' AND `Create_priv` = \'N\' AND `Drop_priv` = \'N\' AND `Grant_priv` = \'N\' AND `References_priv` = \'N\') ORDER BY `User` ASC, `Host` ASC;';
$res1 = PMA_DBI_query($sql_query);
$row1 = PMA_DBI_fetch_assoc($res1);
$sql_query =
'SELECT * FROM `mysql`.`db`'
.' WHERE \'' . $checkprivs . '\''
.' LIKE `Db`'
.' AND NOT (`Select_priv` = \'N\''
.' AND `Insert_priv` = \'N\''
.' AND `Update_priv` = \'N\''
.' AND `Delete_priv` = \'N\''
.' AND `Create_priv` = \'N\''
.' AND `Drop_priv` = \'N\''
.' AND `Grant_priv` = \'N\''
.' AND `References_priv` = \'N\')'
.' ORDER BY `User` ASC, `Host` ASC;';
$res2 = PMA_DBI_query($sql_query);
$row2 = PMA_DBI_fetch_assoc($res2);
if ($row1 || $row2) {
$found = TRUE;
}
} // end if (PMA_MYSQL_INT_VERSION >= 40000) ... else ...