diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index f34146c592f..0b4fc727695 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -85,6 +85,10 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $return['value'] = $value; } + else + { + $return['error'] = $object->error; + } } echo json_encode($return); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b47b5b07f74..c6477a55c26 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -627,6 +627,8 @@ abstract class CommonObject function setValueFrom($table, $id, $field, $value) { global $conf; + + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql.= $field." = '".$this->db->escape($value)."'"; @@ -636,11 +638,13 @@ abstract class CommonObject $resql = $this->db->query($sql); if ($resql) { + $this->db->commit(); return 1; } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror(); + $this->db->rollback(); return -1; } }