Make SHOW DATABASES aware of only_db and hide_db
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
parent
92ccb972e3
commit
9373830149
@ -369,7 +369,7 @@ class Node
|
||||
$query .= "'{$GLOBALS['cfg']['NavigationTreeDbSeparator']}', 1) ";
|
||||
$query .= "DB_first_level ";
|
||||
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
|
||||
$query .= $this->_getWhereClause($searchClause);
|
||||
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
|
||||
$query .= ") t ";
|
||||
$query .= "ORDER BY DB_first_level ASC ";
|
||||
$query .= "LIMIT $pos, {$GLOBALS['cfg']['FirstLevelNavigationItems']}";
|
||||
@ -402,18 +402,12 @@ class Node
|
||||
$query .= "'{$GLOBALS['cfg']['NavigationTreeDbSeparator']}', 1) ";
|
||||
$query .= "DB_first_level ";
|
||||
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
|
||||
$query .= $this->_getWhereClause($searchClause);
|
||||
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
|
||||
$query .= ") t ";
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$query = "SHOW DATABASES ";
|
||||
if (! empty($searchClause)) {
|
||||
$query .= "LIKE '%";
|
||||
$query .= PMA_Util::sqlAddSlashes(
|
||||
$searchClause, true
|
||||
);
|
||||
$query .= "%' ";
|
||||
}
|
||||
$query .= $this->_getWhereClause('Database', $searchClause);
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
return $retval;
|
||||
@ -423,15 +417,16 @@ class Node
|
||||
* Returns the WHERE clause depending on the $searchClause parameter
|
||||
* and the hide_db directive
|
||||
*
|
||||
* @param string $columnName Column name of the column having database names
|
||||
* @param string $searchClause A string used to filter the results of the query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getWhereClause($searchClause = '')
|
||||
private function _getWhereClause($columnName, $searchClause = '')
|
||||
{
|
||||
$whereClause = "WHERE TRUE ";
|
||||
if (! empty($searchClause)) {
|
||||
$whereClause .= "AND `SCHEMA_NAME` LIKE '%";
|
||||
$whereClause .= "AND " . PMA_Util::backquote($columnName) . " LIKE '%";
|
||||
$whereClause .= PMA_Util::sqlAddSlashes(
|
||||
$searchClause, true
|
||||
);
|
||||
@ -439,8 +434,8 @@ class Node
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
||||
$whereClause .= "AND `SCHEMA_NAME` NOT REGEXP '"
|
||||
. $GLOBALS['cfg']['Server']['hide_db'] . "' ";
|
||||
$whereClause .= "AND " . PMA_Util::backquote($columnName)
|
||||
. " NOT REGEXP '" . $GLOBALS['cfg']['Server']['hide_db'] . "' ";
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['cfg']['Server']['only_db'])) {
|
||||
@ -452,7 +447,7 @@ class Node
|
||||
$whereClause .= "AND (";
|
||||
$subClauses = array();
|
||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
||||
$subClauses[] = " `SCHEMA_NAME` LIKE '"
|
||||
$subClauses[] = " " . PMA_Util::backquote($columnName) . " LIKE '"
|
||||
. $each_only_db . "' ";
|
||||
}
|
||||
$whereClause .= implode("OR", $subClauses) . ")";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user