diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-02-25 08:48:28 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-03-17 14:32:14 +0100 |
commit | ee57ddd0b78d83afeeded76057177e990fff9fa4 (patch) | |
tree | 5dfe971a9b85ec09dccad620833a2df356e812c9 /lib | |
parent | 427242cf32da2dbdabada5b6311ae96685fb1112 (diff) | |
download | nextcloud-server-ee57ddd0b78d83afeeded76057177e990fff9fa4.tar.gz nextcloud-server-ee57ddd0b78d83afeeded76057177e990fff9fa4.zip |
Rewrite query for numRows function for SELECT queries
Diffstat (limited to 'lib')
-rw-r--r-- | lib/db.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/db.php b/lib/db.php index 49eeeea430c..379cb342db5 100644 --- a/lib/db.php +++ b/lib/db.php @@ -661,7 +661,14 @@ class DoctrineStatementWrapper { * provide numRows */ public function numRows() { - return $this->statement->rowCount(); + $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; + $queryString = $this->statement->getWrappedStatement()->queryString; + if (preg_match($regex, $queryString, $output) > 0) { + $query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}", PDO::FETCH_NUM); + return $query->execute($this->lastArguments)->fetchColumn(); + }else{ + return $this->statement->rowCount(); + } } /** |