Add instead of replacing when updating motheure::increment
This commit is contained in:
parent
dad2125544
commit
eb7f94dce9
|
@ -85,12 +85,17 @@
|
|||
/* (1) Check if entry exists
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Check if there is an entry for the current machine */
|
||||
$already_exists = is_array(Table::get('motheure')
|
||||
$fetched = Table::get('motheure')
|
||||
->unique()
|
||||
->select('id_motheure')
|
||||
->select('id_machine')
|
||||
->select('count')
|
||||
->whereIdMachine($_SESSION['SATS']['id'])
|
||||
->fetch());
|
||||
->fetch();
|
||||
|
||||
/* (2) Set variable to ease process */
|
||||
$already_exists = is_array($fetched);
|
||||
|
||||
|
||||
|
||||
/* (2) If does not exist, create entry
|
||||
|
@ -115,11 +120,8 @@
|
|||
|
||||
/* (1) Update entry */
|
||||
$updated = Table::get('motheure')
|
||||
->unique()
|
||||
->whereIdMachine($_SESSION['SATS']['id'])
|
||||
->edit([
|
||||
'count' => $count
|
||||
]);
|
||||
->edit([ 'count' => $count + $fetched['count'] ]);
|
||||
|
||||
/* (2) Propagate error */
|
||||
return [ 'error' => ($updated) ? new Error(Err::Success) : new Error(Err::RepoError) ];
|
||||
|
|
Loading…
Reference in New Issue