some minor optimizations
This commit is contained in:
parent
926b2b78fe
commit
721311c909
38
lib/db.php
38
lib/db.php
|
@ -36,7 +36,25 @@ class OC_DB {
|
||||||
static private $affected=0;
|
static private $affected=0;
|
||||||
static private $result=false;
|
static private $result=false;
|
||||||
static private $inTransaction=false;
|
static private $inTransaction=false;
|
||||||
|
static private $prefix=null;
|
||||||
|
static private $type=null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check which backend we should use
|
||||||
|
* @return BACKEND_MDB2 or BACKEND_PDO
|
||||||
|
*/
|
||||||
|
private static function getDBBackend(){
|
||||||
|
$backend=self::BACKEND_MDB2;
|
||||||
|
if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2)
|
||||||
|
$type = OC_Config::getValue( "dbtype", "sqlite" );
|
||||||
|
if($type=='sqlite3') $type='sqlite';
|
||||||
|
$drivers=PDO::getAvailableDrivers();
|
||||||
|
if(array_search($type,$drivers)!==false){
|
||||||
|
$backend=self::BACKEND_PDO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief connects to the database
|
* @brief connects to the database
|
||||||
* @returns true if connection can be established or nothing (die())
|
* @returns true if connection can be established or nothing (die())
|
||||||
|
@ -48,15 +66,7 @@ class OC_DB {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(is_null($backend)){
|
if(is_null($backend)){
|
||||||
$backend=self::BACKEND_MDB2;
|
$backend=self::getDBBackend();
|
||||||
if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2)
|
|
||||||
$type = OC_Config::getValue( "dbtype", "sqlite" );
|
|
||||||
if($type=='sqlite3') $type='sqlite';
|
|
||||||
$drivers=PDO::getAvailableDrivers();
|
|
||||||
if(array_search($type,$drivers)!==false){
|
|
||||||
$backend=self::BACKEND_PDO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if($backend==self::BACKEND_PDO){
|
if($backend==self::BACKEND_PDO){
|
||||||
self::connectPDO();
|
self::connectPDO();
|
||||||
|
@ -423,8 +433,14 @@ class OC_DB {
|
||||||
private static function processQuery( $query ){
|
private static function processQuery( $query ){
|
||||||
self::connect();
|
self::connect();
|
||||||
// We need Database type and table prefix
|
// We need Database type and table prefix
|
||||||
$type = OC_Config::getValue( "dbtype", "sqlite" );
|
if(is_null(self::$type)){
|
||||||
$prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
|
self::$type=OC_Config::getValue( "dbtype", "oc_" );
|
||||||
|
}
|
||||||
|
$type = self::$type;
|
||||||
|
if(is_null(self::$prefix)){
|
||||||
|
self::$prefix=OC_Config::getValue( "dbtableprefix", "oc_" );
|
||||||
|
}
|
||||||
|
$prefix = self::$prefix;
|
||||||
|
|
||||||
// differences in escaping of table names ('`' for mysql) and getting the current timestamp
|
// differences in escaping of table names ('`' for mysql) and getting the current timestamp
|
||||||
if( $type == 'sqlite' || $type == 'sqlite3' ){
|
if( $type == 'sqlite' || $type == 'sqlite3' ){
|
||||||
|
|
13
lib/l10n.php
13
lib/l10n.php
|
@ -261,17 +261,14 @@ class OC_L10N{
|
||||||
public static function findAvailableLanguages($app=null){
|
public static function findAvailableLanguages($app=null){
|
||||||
$available=array('en');//english is always available
|
$available=array('en');//english is always available
|
||||||
$dir = self::findI18nDir($app);
|
$dir = self::findI18nDir($app);
|
||||||
if(file_exists($dir)){
|
if(is_dir($dir)){
|
||||||
$dh = opendir($dir);
|
$files=scandir($dir);
|
||||||
while(($file = readdir($dh)) !== false){
|
foreach($files as $file){
|
||||||
if(substr($file, -4, 4) == '.php' and (strlen($file) == 6 || strlen($file) == 9)){
|
if(substr($file, -4, 4) == '.php'){
|
||||||
$i = substr($file, 0, -4);
|
$i = substr($file, 0, -4);
|
||||||
if($i != ''){
|
$available[] = $i;
|
||||||
$available[] = $i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dh);
|
|
||||||
}
|
}
|
||||||
return $available;
|
return $available;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue