diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-07-30 20:53:21 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-07-31 19:34:30 +0200 |
commit | 795e78809f55be762fb07d9a179bbdffa7aefbd9 (patch) | |
tree | f2ba0402ccb00165ef7b623aea5345fbc1ce2f5b /lib/db.php | |
parent | 3aff7a298c23837b070507a0644b89a8a5c026be (diff) | |
download | nextcloud-server-795e78809f55be762fb07d9a179bbdffa7aefbd9.tar.gz nextcloud-server-795e78809f55be762fb07d9a179bbdffa7aefbd9.zip |
add oracle to install & setup
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/lib/db.php b/lib/db.php index 08bd06df95e..a2dbc5dfac9 100644 --- a/lib/db.php +++ b/lib/db.php @@ -44,15 +44,18 @@ class OC_DB { * @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=='oci') { //oracle also always needs mdb2 + return self::BACKEND_MDB2; + } if($type=='sqlite3') $type='sqlite'; $drivers=PDO::getAvailableDrivers(); if(array_search($type,$drivers)!==false){ - $backend=self::BACKEND_PDO; + return self::BACKEND_PDO; } } + return self::BACKEND_MDB2; } /** @@ -129,7 +132,14 @@ class OC_DB { $dsn='pgsql:dbname='.$name.';host='.$host; } break; - } + case 'oci': + if ($port) { + $dsn = 'oci:dbname=//' . $host . ':' . $port . '/' . $name; + } else { + $dsn = 'oci:dbname=//' . $host . '/' . $name; + } + break; + } try{ self::$PDO=new PDO($dsn,$user,$pass,$opts); }catch(PDOException $e){ @@ -345,9 +355,17 @@ class OC_DB { $file2 = 'static://db_scheme'; $content = str_replace( '*dbname*', $CONFIG_DBNAME, $content ); $content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content ); - if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't - $content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content ); - } + /* FIXME: REMOVE this commented code + * actually mysql, postgresql, sqlite and oracle support CUURENT_TIMESTAMP + * http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html + * http://www.postgresql.org/docs/8.1/static/functions-datetime.html + * http://www.sqlite.org/lang_createtable.html + * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm + + if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't + $content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content ); + } + */ file_put_contents( $file2, $content ); // Try to create tables @@ -363,10 +381,17 @@ class OC_DB { // if(OC_Config::getValue('dbtype','sqlite')=='sqlite'){ // $definition['overwrite']=true;//always overwrite for sqlite // } + if(OC_Config::getValue('dbtype','sqlite')==='oci'){ + unset($definition['charset']); //or MDB2 tries SHUTDOWN IMMEDIATE + $oldname = $definition['name']; + $definition['name']=OC_Config::getValue( "dbuser", $oldname ); + } + $ret=self::$schema->createDatabase( $definition ); // Die in case something went wrong if( $ret instanceof MDB2_Error ){ + echo (self::$MDB2->getDebugOutput()); die ($ret->getMessage() . ': ' . $ret->getUserInfo()); } @@ -397,9 +422,16 @@ class OC_DB { $file2 = 'static://db_scheme'; $content = str_replace( '*dbname*', $previousSchema['name'], $content ); $content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content ); + /* FIXME: REMOVE this commented code + * actually mysql, postgresql, sqlite and oracle support CUURENT_TIMESTAMP + * http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html + * http://www.postgresql.org/docs/8.1/static/functions-datetime.html + * http://www.sqlite.org/lang_createtable.html + * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't $content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content ); } + */ file_put_contents( $file2, $content ); $op = self::$schema->updateDatabase($file2, $previousSchema, array(), false); @@ -464,7 +496,7 @@ class OC_DB { }elseif( $type == 'mysql' ){ $query = str_replace( 'NOW()', 'CURRENT_TIMESTAMP', $query ); $query = str_replace( 'now()', 'CURRENT_TIMESTAMP', $query ); - }elseif( $type == 'pgsql' ){ + }elseif( $type == 'pgsql' || $type == 'oci' ){ $query = str_replace( '`', '"', $query ); $query = str_replace( 'NOW()', 'CURRENT_TIMESTAMP', $query ); $query = str_replace( 'now()', 'CURRENT_TIMESTAMP', $query ); |