Skip to content
Snippets Groups Projects
Commit 1f7bf57e authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #1195 from owncloud/cache_prepared

Cache prepared statements in OC_DB
parents 0398bfff f18fc1c5
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,8 @@ class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
static private $preparedQueries = array();
/**
* @var MDB2_Driver_Common
*/
......@@ -121,6 +123,7 @@ class OC_DB {
return true;
}
}
self::$preparedQueries = array();
// The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" );
......@@ -201,6 +204,7 @@ class OC_DB {
return true;
}
}
self::$preparedQueries = array();
// The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" );
......@@ -321,7 +325,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 +352,9 @@ class OC_DB {
}
$result=new PDOStatementWrapper($result);
}
if (is_null($limit) || $limit == -1) {
self::$preparedQueries[$rawQuery] = $result;
}
return $result;
}
......@@ -588,7 +600,7 @@ class OC_DB {
error_log('DB error: '.$entry);
OC_Template::printErrorPage( $entry );
}
if($result->numRows() == 0) {
$query = 'INSERT INTO "' . $table . '" ("'
. implode('","', array_keys($input)) . '") VALUES("'
......@@ -623,7 +635,7 @@ class OC_DB {
return $result->execute();
}
/**
* @brief does minor changes to query
* @param string $query Query string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment