summaryrefslogtreecommitdiff
path: root/core/classes/Database.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/classes/Database.php')
-rw-r--r--core/classes/Database.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/classes/Database.php b/core/classes/Database.php
index 8cac479..0a8a10a 100644
--- a/core/classes/Database.php
+++ b/core/classes/Database.php
@@ -14,6 +14,8 @@ class Database {
private $result = null;
+ private $rowCount;
+
/** METHODS
* -------------------------------------------------------------------------
@@ -78,6 +80,25 @@ class Database {
}
+
+ /** rowCount
+ *
+ * returns the number of affected rows from the last modification query
+ * (that inludes any of INSERT, UPDATE or DELETE; not the SELECT ones)
+ *
+ * NOTE:
+ * originally in php PDO driver, rowCount is applied onto the stamement;
+ * here it is applied onto the actual object, making the call much easier
+ *
+ * @param void;
+ * @return (int) : number of affected rows
+ */
+ public function rowCount()
+ {
+ return $this->rowCount;
+ }
+
+
/** query
* ---
* set and execute a query safely;
@@ -103,6 +124,9 @@ class Database {
}
+ // keep rowCount (valid for INSERT, UPDATE, DELETE)
+ $this->rowCount = $stmt->rowCount();
+
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$this->result = $result;