From a85d54e1e801b07a152a717fbfca08c8eadad201 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sat, 23 Mar 2013 12:57:58 -0400
Subject: [PATCH] Hack to reset PDO statement iterators after counting

---
 program/lib/Roundcube/rcube_db.php |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 49bbe5c..ec61cb6 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -444,6 +444,7 @@
      *
      * @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 @@
                 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;
             }
         }
 

--
Gitblit v1.9.1