diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-03-24 17:30:34 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-03-24 17:30:34 +0100 |
commit | 24e88e91f7ebac132fa356762b0cd544d42cef9f (patch) | |
tree | 3b99b6c2237fb26541a133f78405faffcddd5240 /program/lib/Roundcube/rcube_db.php | |
parent | a26c031621410f030751eae404490a10498583d7 (diff) | |
parent | 7889c57b772dbf722639894bd572c767424c8b84 (diff) |
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/lib/Roundcube/rcube_db.php')
-rw-r--r-- | program/lib/Roundcube/rcube_db.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 49bbe5c6e..4e6684c51 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -444,17 +444,20 @@ 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) { if ($result || ($result === null && ($result = $this->last_result))) { // repeat query with SELECT COUNT(*) ... - if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i', $result->queryString, $m)) { + if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) { $query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM); 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; } } |