summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-01-15 20:20:39 +0100
committerRobin Appelman <icewind@owncloud.com>2013-01-15 20:21:06 +0100
commita08490364d081ff5030ab45d612235cb0ed6299c (patch)
treef173ae2c415567c4a86cdf425dd69bb542f62a7c /lib/db.php
parentbb9cc227c2583adc6b51a1f6d75a9fc8333836b9 (diff)
downloadnextcloud-server-a08490364d081ff5030ab45d612235cb0ed6299c.tar.gz
nextcloud-server-a08490364d081ff5030ab45d612235cb0ed6299c.zip
Cache prepared statements in OC_DB
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/db.php b/lib/db.php
index 74e7ca5b0e0..c5908afe69b 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -41,6 +41,8 @@ class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
+ static private $preparedQueries = array();
+
/**
* @var MDB2_Driver_Common
*/
@@ -321,7 +323,12 @@ class OC_DB {
$query.=$limitsql;
}
}
+ } else {
+ if (isset(self::$preparedQueries[$query])) {
+ return self::$preparedQueries[$query];
+ }
}
+ $rawQuery = $query;
// Optimize the query
$query = self::processQuery( $query );
@@ -343,6 +350,9 @@ class OC_DB {
}
$result=new PDOStatementWrapper($result);
}
+ if (is_null($limit) || $limit == -1) {
+ self::$preparedQueries[$rawQuery] = $result;
+ }
return $result;
}