From 544dc3cfed4c94112b2b1c83f286c893859751a5 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 19 Mar 2014 20:35:09 +0000 Subject: [PATCH] Return the number of rows modified by the request git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1226 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dblayer.php b/dblayer.php index db9765a..d830d1f 100644 --- a/dblayer.php +++ b/dblayer.php @@ -173,7 +173,8 @@ class dblayer extends PDO return $res; } - /** Update the key tuple with the provided datas */ + /** Update the key tuple with the provided datas + Return the number of rows modified */ function update ($updatekey, $datas) { if ($this->db === null) @@ -186,6 +187,8 @@ class dblayer extends PDO if (array_key_exists ($key, $datas)) $datasOK[$key] = $datas[$key]; } + if (count ($datasOK) === 0) + throw new Exception (_("Don't receive any field to display"), 501); $req = "UPDATE `".$this->table."` SET "; $i = 0; @@ -218,6 +221,7 @@ class dblayer extends PDO } $st->execute (); + return $st->rowCount(); } /** Delete a tuple identified by its primary key