add edit to automatization

This commit is contained in:
unknown
2019-09-19 20:05:32 +02:00
parent e2be9e57ee
commit 03ea63e839
3 changed files with 45 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ class AutomationManager{
return Db::command ('UPDATE automation SET active = ? WHERE automation_id=?', array ($flipedValue,$automationId));
}
public function create ($name, $onDays, $doCode, $ifCode) {
public function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
$scene = array (
'name' => $name,
'on_days' => $onDays,
@@ -21,7 +21,11 @@ class AutomationManager{
'do_something' => $doCode,
);
try {
Db::add ('automation', $scene);
if ($automationId == "") {
Db::add ('automation', $scene);
} else {
Db::edit ('automation', $scene, 'WHERE automation_id = ?', array ($automationId));
}
} catch(PDOException $error) {
echo $error->getMessage();
die();