From 9dfad4886d569984b490ecf270e6d3033824efed Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 22 Dec 2017 16:12:34 +0100 Subject: [PATCH] fix saving Monitors --- web/includes/Monitor.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 157088e83..b3a9ad633 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -293,8 +293,8 @@ private $control_fields = array( } return $filters; } - public function save( $new_values = null ) { + public function save( $new_values = null ) { if ( $new_values ) { foreach ( $new_values as $k=>$v ) { @@ -302,8 +302,10 @@ private $control_fields = array( } } - $sql = 'UPDATE Monitors SET '.implode(', ', array_map( function($field) {return $field.'=?';}, array_keys( $this->defaults ) ) ) . ' WHERE Id=?'; - $values = array_map( function($field){return $this->{$field};}, $this->fields ); + $fields = array_keys( $this->defaults ); + + $sql = 'UPDATE Monitors SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?'; + $values = array_map( function($field){return $this->{$field};}, $fields ); $values[] = $this->{'Id'}; dbQuery( $sql, $values ); } // end function save