summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-03-23 17:57:58 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2013-04-04 21:14:46 +0200
commitb2c66d03317a75cdc83e878541627534d43db1f7 (patch)
tree21f8a5bddd76094f15f2fc6e8e963144ac43ff68
parentbd723e565dfbbbb06fa5b15e138a4d51e7cdea10 (diff)
Hack to reset PDO statement iterators after counting
-rw-r--r--program/lib/Roundcube/rcube_db.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 631851975..113ed84bf 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -444,6 +444,7 @@ class rcube_db
*
* @param mixed $result Optional query handle
* @return mixed Number of rows or false on failure
+ * @deprecated This method shows very poor performance and should be avoided.
*/
public function num_rows($result = null)
{
@@ -454,7 +455,9 @@ class rcube_db
return $query ? intval($query->fetchColumn(0)) : false;
}
else {
- return count($result->fetchAll());
+ $num = count($result->fetchAll());
+ $result->execute(); // re-execute query because there's no seek(0)
+ return $num;
}
}