get all db comments at once, not with single queries

This commit is contained in:
Sebastian Mendel
2008-01-21 13:52:26 +00:00
parent 2bb7833f50
commit b7733ad022
2 changed files with 51 additions and 6 deletions

View File

@@ -270,15 +270,18 @@ require_once './libraries/List.class.php';
{
$dbgroups = array();
$parts = array();
if ($GLOBALS['cfg']['ShowTooltip']
&& $GLOBALS['cfgRelation']['commwork']) {
$db_tooltips = PMA_getDbComments();
}
foreach ($this->getLimitedItems($offset, $count) as $key => $db) {
// garvin: Get comments from PMA comments table
$db_tooltip = '';
if ($GLOBALS['cfg']['ShowTooltip']
&& $GLOBALS['cfgRelation']['commwork']) {
$_db_tooltip = PMA_getDbComment($db);
if ($_db_tooltip) {
$db_tooltip = $_db_tooltip;
}
if (isset($db_tooltips[$db])) {
$db_tooltip = $_db_tooltips[$db];
}
if ($GLOBALS['cfg']['LeftFrameDBTree']

View File

@@ -568,6 +568,48 @@ function PMA_getDbComment($db)
return $comment;
} // end of the 'PMA_getDbComment()' function
/**
* Gets the comment for a db
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
* @author lem9
* @access public
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_DBI_num_rows()
* @uses PMA_DBI_fetch_assoc()
* @uses PMA_DBI_free_result()
* @uses PMA_getRelationsParam()
* @uses PMA_backquote()
* @uses PMA_sqlAddslashes()
* @uses PMA_query_as_cu()
* @uses strlen()
* @param string the name of the db to check for
* @return string comment
*/
function PMA_getDbComments()
{
$cfgRelation = PMA_getRelationsParam();
$comments = array();
if ($cfgRelation['commwork']) {
// pmadb internal db comment
$com_qry = "
SELECT `db_name`, `comment`
FROM " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['column_info']) . "
WHERE `column_name` = '(db_comment)'";
$com_rs = PMA_query_as_cu($com_qry, true, PMA_DBI_QUERY_STORE);
if ($com_rs && PMA_DBI_num_rows($com_rs) > 0) {
while ($row = PMA_DBI_fetch_assoc($com_rs)) {
$comments[$row['db_name']] = $row['comment'];
}
}
PMA_DBI_free_result($com_rs);
}
return $comments;
} // end of the 'PMA_getDbComments()' function
/**
* Set a database comment to a certain value.
*