summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-05-17 01:06:22 +0200
committerRobin Appelman <icewind@owncloud.com>2012-05-17 01:06:22 +0200
commitaac9629e88a572341775720109e783ed70858cc2 (patch)
tree74cdf6db65ffa2f09fcd9decb0bbdc3a9b7f2679 /lib
parent5fe7200a7ff7360b33e7c762f1406bcb4c9b6a5c (diff)
downloadnextcloud-server-aac9629e88a572341775720109e783ed70858cc2.tar.gz
nextcloud-server-aac9629e88a572341775720109e783ed70858cc2.zip
add support for custom ports for mysql/pgsql by adding :portnumber to the database host
Diffstat (limited to 'lib')
-rw-r--r--lib/db.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/db.php b/lib/db.php
index 9f951d645e4..08bd06df95e 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -96,6 +96,11 @@ class OC_DB {
$user = OC_Config::getValue( "dbuser", "" );
$pass = OC_Config::getValue( "dbpassword", "" );
$type = OC_Config::getValue( "dbtype", "sqlite" );
+ if(strpos($host,':')){
+ list($host,$port)=explode(':',$host,2);
+ }else{
+ $port=false;
+ }
$opts = array();
$datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
@@ -110,11 +115,19 @@ class OC_DB {
$dsn='sqlite:'.$datadir.'/'.$name.'.db';
break;
case 'mysql':
- $dsn='mysql:dbname='.$name.';host='.$host;
+ if($port){
+ $dsn='mysql:dbname='.$name.';host='.$host.';port='.$port;
+ }else{
+ $dsn='mysql:dbname='.$name.';host='.$host;
+ }
$opts[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'UTF8'";
break;
case 'pgsql':
- $dsn='pgsql:dbname='.$name.';host='.$host;
+ if($port){
+ $dsn='pgsql:dbname='.$name.';host='.$host.';port='.$port;
+ }else{
+ $dsn='pgsql:dbname='.$name.';host='.$host;
+ }
break;
}
try{