Add transaction db missing
This commit is contained in:
parent
481bd93ab8
commit
99f632b3ff
@ -134,6 +134,8 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$result = $object->create($user);
|
$result = $object->create($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
// Creation OK
|
// Creation OK
|
||||||
@ -141,14 +143,19 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
$categories = GETPOST('categories', 'array:int');
|
$categories = GETPOST('categories', 'array:int');
|
||||||
$object->setCategories($categories);
|
$object->setCategories($categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
|
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
|
||||||
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
|
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
|
||||||
|
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
if (empty($noback)) {
|
if (empty($noback)) {
|
||||||
header("Location: " . $urltogo);
|
header("Location: " . $urltogo);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$db->rollback();
|
||||||
|
|
||||||
$error++;
|
$error++;
|
||||||
// Creation KO
|
// Creation KO
|
||||||
if (!empty($object->errors)) {
|
if (!empty($object->errors)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user