From b7733ad022a22c157d9bdd339744eb4e75c63fe2 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 21 Jan 2008 13:52:26 +0000 Subject: [PATCH] get all db comments at once, not with single queries --- libraries/List_Database.class.php | 15 ++++++----- libraries/relation.lib.php | 42 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php index 6c578811b..1def30156 100644 --- a/libraries/List_Database.class.php +++ b/libraries/List_Database.class.php @@ -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'] diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index b4abad9aa..419384b61 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -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 + * @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. *