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();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction();
|
||||
$result = $this->send($_action)->getResult();
|
||||
$result = (array)$this->send($_action)->getResult();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class dbinterface
|
|||
|
||||
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 = '';
|
||||
$stmts = '';
|
||||
if ($dataid == '') {
|
||||
|
@ -171,18 +171,19 @@ class dbinterface
|
|||
} elseif (!empty($stmts)) {
|
||||
$stmts->execute();
|
||||
$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;
|
||||
}
|
||||
|
||||
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();
|
||||
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $key => $rowArray) {
|
||||
$settingsFromDb[$rowArray['keyword']] = $rowArray;
|
||||
unset($settingsFromDb[$key]);
|
||||
}
|
||||
$settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
|
||||
return $settingsFromDb;
|
||||
}
|
||||
|
||||
|
|
|
@ -298,13 +298,11 @@ trait ajaxHelper {
|
|||
if (!empty($activeDevices)) {
|
||||
foreach ($lineList as $key => $lineArr) {
|
||||
if (isset($activeDevices[$lineArr['mac']])) {
|
||||
$tpm_info = $activeDevices[$lineArr['mac']];
|
||||
if (!empty($tpm_info)) {
|
||||
$lineList[$key]['line_status'] = $tpm_info['status'];
|
||||
$lineList[$key]['line_status'] .= " | {$tpm_info['act']}";
|
||||
$actDevStat = $activeDevices[$lineArr['mac']];
|
||||
if (!empty($actDevStat)) {
|
||||
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
||||
} else {
|
||||
$lineList[$key]['line_status'] = '';
|
||||
$lineList[$key]['line_status'] .= '|';
|
||||
$lineList[$key]['line_status'] = '|';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue