From 7ee06a68bcb708af6d6c47bd062c7704c87e2c4b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 28 Oct 2011 12:26:21 +0200 Subject: [PATCH] Fix: add sql error --- htdocs/core/ajax/saveinplace.php | 4 ++++ htdocs/core/class/commonobject.class.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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; } }