Simplify tests

Use Isset instaed of empty twice
This commit is contained in:
steve-lad 2021-05-30 14:27:45 +02:00
parent 7cf12356c1
commit 85e4bce407

View file

@ -93,27 +93,13 @@ class Sccp extends \FreePBX\modules\Core\Driver {
$sqlCol = 'name'; $sqlCol = 'name';
$sqlVal = "\'{$id}\'"; $sqlVal = "\'{$id}\'";
foreach($this->data_fld as $key => $val) { foreach($this->data_fld as $key => $val) {
if (!empty($settings[$val]) ) { if (isset($settings[$val]['value'])){
if (!empty($settings[$val]['value'])){ $sqlCol .= ", {$key}";
$sqlCol .= ", {$key}"; $sqlVal .= ", \' {$settings[$val]['value']} \'";
$sqlVal .= ", \' {$settings[$val]['value']} \'";
}
} }
} }
$sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} );"; $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} );";
/*
$sql = 'REPLACE INTO sccpline (name';
$sqlv = 'values ("'.$id.'"';
foreach($this->data_fld as $key => $val) {
if (!empty($settings[$val]) ) {
if (!empty($settings[$val]['value'])){
$sql .= ', '.$key;
$sqlv .= ", '".$settings[$val]['value']."' ";
}
}
}
$sql .= ") ".$sqlv.");";
*/
$sth = $this->database->prepare($sql); $sth = $this->database->prepare($sql);
$sth->execute(); $sth->execute();
return true; return true;