Device [Class]: Updates for PHP 8.1

This commit is contained in:
fusionate 2023-05-25 17:41:58 +00:00
parent d0357b6124
commit 798001bb23
No known key found for this signature in database
1 changed files with 9 additions and 7 deletions

View File

@ -1052,11 +1052,11 @@
$uuids[] = "'".$record['uuid']."'"; $uuids[] = "'".$record['uuid']."'";
} }
} }
if (is_array($uuids) && @sizeof($uuids) != 0) { if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database; $database = new database;
$rows = $database->select($sql, $parameters, 'all'); $rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
@ -1067,10 +1067,12 @@
//build update array //build update array
$x = 0; $x = 0;
foreach ($states as $uuid => $state) { if (!empty($states) && is_array($states) && @sizeof($states) != 0) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; foreach ($states as $uuid => $state) {
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
$x++; $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
$x++;
}
} }
//save the changes //save the changes
@ -1128,7 +1130,7 @@
} }
//create insert array from existing data //create insert array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) { if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";