1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-16 11:34:10 +02:00

Separate get_key_vals function

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1244 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2009-11-18 12:32:39 +00:00
parent 14ec96a090
commit 1ee3dd97d6
2 changed files with 14 additions and 11 deletions

View File

@@ -127,10 +127,7 @@ ORDER BY ORDINAL_POSITION");
// uses constant number of queries to get the descriptions, join would be complex, multiple queries would be slow
$descriptions = $this->values[$foreignKey["table"]];
if (!$descriptions) {
$result = $connection->query("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " WHERE $id IN (" . implode(", ", $ids) . ")");
while ($row = $result->fetch_row()) {
$descriptions[$row[0]] = $row[1];
}
$descriptions = get_key_vals("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " WHERE $id IN (" . implode(", ", $ids) . ")");
}
// use the descriptions
foreach ($rows as $n => $row) {
@@ -482,13 +479,9 @@ ORDER BY ORDINAL_POSITION");
if (strlen($name)) {
$return = &$this->values[$foreignKey["table"]];
if (!isset($return)) {
$result = $connection->query("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " ORDER BY 2 LIMIT 1001");
$return = array("" => "") + get_key_vals("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " ORDER BY 2 LIMIT 1001");
if (count($return) > 1001) {
$return = array();
if ($result->num_rows < 1001) { // optionlist with more than 1000 options would be too big
$return[""] = "";
while ($row = $result->fetch_row()) {
$return[$row[0]] = $row[1];
}
}
}
return $return;

View File

@@ -3,3 +3,13 @@ function email_header($header) {
// iconv_mime_encode requires PHP 5, imap_8bit requires IMAP extension
return "=?UTF-8?B?" . base64_encode($header) . "?="; //! split long lines
}
function get_key_vals($query) {
global $connection;
$return = array();
$result = $connection->query($query);
while ($row = $result->fetch_row()) {
$return[$row[0]] = $row[1];
}
return $return;
}