From d896a8c2d97a79b4fccc180e595a7ecb4a0945f1 Mon Sep 17 00:00:00 2001 From: Olov Danielson Date: Sun, 10 Jan 2010 17:14:32 +0000 Subject: [PATCH] Added rowcount function to db --- ykval-db.php | 21 +++++++++++++++++++++ ykval-synclib.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ykval-db.php b/ykval-db.php index a9fce4d..027c542 100644 --- a/ykval-db.php +++ b/ykval-db.php @@ -353,10 +353,31 @@ or false on failure. return $this->query($query, false); } + + /** + * Function to do a custom query on database connection + * + * @param string $query Database query + * @return mixed + * + */ public function customQuery($query) { return $this->query($query, true); } + + /** + * Function to do a custom query on database connection + * + * @return int number of rows affected by last statement or 0 if database connection is not functional. + * + */ + public function rowCount() + { + if($this->dbh) return $this->dbh->rowCount(); + else return 0; + } + /** * helper function used to get rows from Db table in reversed order. * defaults to obtaining 1 row. diff --git a/ykval-synclib.php b/ykval-synclib.php index b91b668..4e17635 100644 --- a/ykval-synclib.php +++ b/ykval-synclib.php @@ -210,7 +210,7 @@ class SyncLib error_log("ykval-synclib:critical: failed to update internal DB with new counters"); return false; } else { - if (mysql_affected_rows()>0) $this->log("notice", "updated database ", $params); + if ($this->db->rowCount()>0) $this->log("notice", "updated database ", $params); else $this->log('notice', 'database not updated', $params); return true; }