Work on a more efficient way to handle app_uuid_exists on a larger scale.

This commit is contained in:
markjcrane
2016-07-01 13:42:44 -06:00
parent d5b053ba74
commit 545eac8ca0
+25 -13
View File
@@ -228,21 +228,32 @@ include "root.php";
} }
private function app_uuid_exists() { private function app_uuid_exists() {
$sql = "select domain_uuid from v_dialplans "; if (!isset($_SESSION['app_uuid'][$this->domain_uuid]) {
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) "; $sql = "select domain_uuid from v_dialplans ";
$sql .= "and app_uuid = '".$this->app_uuid."' "; $sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) ";
$prep_statement = $this->db->prepare(check_sql($sql)); //$sql .= "and app_uuid = '".$this->app_uuid."' ";
if ($prep_statement) { $prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute(); if ($prep_statement) {
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $prep_statement->execute();
if (count($result)) { $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
return true; foreach ($result as $row) {
} if ($row['domain_uuid'] == null) {
else { $dialplan_domain = 'global';
return false; }
else {
$dialplan_domain = $row['domain_uuid']
}
$_SESSION['app_uuid'][$dialplan_domain][$row['app_uuid']] = $row['dialplan_uuid'];
}
} }
unset($sql, $prep_statement, $result);
}
if (isset($_SESSION['app_uuid']['global'][$this->app_uuid]) || isset($_SESSION['app_uuid'][$this->domain_uuid][$this->app_uuid])) {
return true;
}
else {
return false;
} }
unset($sql, $prep_statement, $result);
} }
public function dialplan_exists() { public function dialplan_exists() {
@@ -440,6 +451,7 @@ include "root.php";
$prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset($prep_statement,$sql)
$x = 0; $y = 0; $x = 0; $y = 0;
if (isset($dialplans)) foreach ($dialplans as &$row) { if (isset($dialplans)) foreach ($dialplans as &$row) {
//if the previous dialplan uuid has not been set then set it //if the previous dialplan uuid has not been set then set it