Cache prepared statements in OC_DB

This commit is contained in:
Robin Appelman 2013-01-15 20:20:39 +01:00
parent bb9cc227c2
commit a08490364d
1 changed files with 10 additions and 0 deletions

View File

@ -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;
}