Remove one trip to the database.
This commit is contained in:
+16
-16
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
@@ -236,8 +236,8 @@ if ($db_type == "pgsql") {
|
|||||||
if (strlen($_SESSION["domain_uuid"]) == 0) {
|
if (strlen($_SESSION["domain_uuid"]) == 0) {
|
||||||
//get the domain
|
//get the domain
|
||||||
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
|
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
|
||||||
//natural sort domains into array
|
//get the domains from the database
|
||||||
$sql = "select domain_name from v_domains";
|
$sql = "select * from v_domains";
|
||||||
$prep_statement = $db->prepare($sql);
|
$prep_statement = $db->prepare($sql);
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
@@ -246,21 +246,21 @@ if ($db_type == "pgsql") {
|
|||||||
$domain_names[] = $row['domain_name'];
|
$domain_names[] = $row['domain_name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($result, $prep_statement);
|
unset($prep_statement);
|
||||||
|
//put the domains in natural order
|
||||||
natsort($domain_names);
|
natsort($domain_names);
|
||||||
//get the domains in the natural sort order
|
//build the domains array in the correct order
|
||||||
$n = 1;
|
|
||||||
$sql = "select * from v_domains order by case ";
|
|
||||||
foreach ($domain_names as $dn) {
|
foreach ($domain_names as $dn) {
|
||||||
$sql .= "when domain_name = '".$dn."' then ".$n." ";
|
foreach ($result as $row) {
|
||||||
$n++;
|
if ($row['domain_name'] == $dn) {
|
||||||
|
$domains[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sql .= "else ".$n." end ";
|
unset($result);
|
||||||
$prep_statement = $db->prepare($sql);
|
|
||||||
$prep_statement->execute();
|
foreach($domains as $row) {
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
if (count($domains) == 1) {
|
||||||
foreach($result as $row) {
|
|
||||||
if (count($result) == 1) {
|
|
||||||
$_SESSION["domain_uuid"] = $row["domain_uuid"];
|
$_SESSION["domain_uuid"] = $row["domain_uuid"];
|
||||||
$_SESSION["domain_name"] = $row['domain_name'];
|
$_SESSION["domain_name"] = $row['domain_name'];
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ if ($db_type == "pgsql") {
|
|||||||
$_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name'];
|
$_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name'];
|
||||||
$_SESSION['domains'][$row['domain_uuid']]['domain_description'] = $row['domain_description'];
|
$_SESSION['domains'][$row['domain_uuid']]['domain_description'] = $row['domain_description'];
|
||||||
}
|
}
|
||||||
unset($result, $prep_statement);
|
unset($domains, $prep_statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the software name
|
//get the software name
|
||||||
|
|||||||
Reference in New Issue
Block a user