Optimise database calls
Remove unnecessary post processing on returned object
This commit is contained in:
parent
3475efc2c6
commit
3a53e9ac8b
|
@ -392,7 +392,7 @@ class aminterface
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($this->_connect_state) {
|
if ($this->_connect_state) {
|
||||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction();
|
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction();
|
||||||
$result = $this->send($_action)->getResult();
|
$result = (array)$this->send($_action)->getResult();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class dbinterface
|
||||||
|
|
||||||
public function getSccpDeviceTableData($dataid, $data = array())
|
public function getSccpDeviceTableData($dataid, $data = array())
|
||||||
{
|
{
|
||||||
// $stmt is a single row fetch, $stmts is a fetchAll.
|
// $stmt is a single row fetch, $stmts is a fetchAll while stmtU is fetchAll UNIQUE
|
||||||
$stmt = '';
|
$stmt = '';
|
||||||
$stmts = '';
|
$stmts = '';
|
||||||
if ($dataid == '') {
|
if ($dataid == '') {
|
||||||
|
@ -171,18 +171,19 @@ class dbinterface
|
||||||
} elseif (!empty($stmts)) {
|
} elseif (!empty($stmts)) {
|
||||||
$stmts->execute();
|
$stmts->execute();
|
||||||
$raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC);
|
$raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
} elseif (!empty($stmtU)) {
|
||||||
|
//returns an assoc array indexed on first field
|
||||||
|
$stmtU->execute();
|
||||||
|
$raw_settings = $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
|
||||||
}
|
}
|
||||||
return $raw_settings;
|
return $raw_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_db_SccpSetting()
|
public function get_db_SccpSetting()
|
||||||
{
|
{
|
||||||
$stmt = $this->db->prepare('SELECT keyword, seq, type, data, systemdefault FROM sccpsettings ORDER BY type, seq');
|
$stmt = $this->db->prepare('SELECT keyword, sccpsettings.* FROM sccpsettings ORDER BY type, seq');
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $key => $rowArray) {
|
$settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
|
||||||
$settingsFromDb[$rowArray['keyword']] = $rowArray;
|
|
||||||
unset($settingsFromDb[$key]);
|
|
||||||
}
|
|
||||||
return $settingsFromDb;
|
return $settingsFromDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,13 +298,11 @@ trait ajaxHelper {
|
||||||
if (!empty($activeDevices)) {
|
if (!empty($activeDevices)) {
|
||||||
foreach ($lineList as $key => $lineArr) {
|
foreach ($lineList as $key => $lineArr) {
|
||||||
if (isset($activeDevices[$lineArr['mac']])) {
|
if (isset($activeDevices[$lineArr['mac']])) {
|
||||||
$tpm_info = $activeDevices[$lineArr['mac']];
|
$actDevStat = $activeDevices[$lineArr['mac']];
|
||||||
if (!empty($tpm_info)) {
|
if (!empty($actDevStat)) {
|
||||||
$lineList[$key]['line_status'] = $tpm_info['status'];
|
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
||||||
$lineList[$key]['line_status'] .= " | {$tpm_info['act']}";
|
|
||||||
} else {
|
} else {
|
||||||
$lineList[$key]['line_status'] = '';
|
$lineList[$key]['line_status'] = '|';
|
||||||
$lineList[$key]['line_status'] .= '|';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue