diff options
author | Administrator <Administrator@WINDOWS-2012> | 2013-02-10 14:08:00 +0100 |
---|---|---|
committer | Administrator <Administrator@WINDOWS-2012> | 2013-02-10 14:08:00 +0100 |
commit | 4e5a3fbcafcaa0cdaba351dfb307b0000179c832 (patch) | |
tree | 117b3b3220d3dc485ba369db7676cd6a3366840c /lib/db.php | |
parent | 41ec976fd74320c379f95d05d3a490310f06402e (diff) | |
download | nextcloud-server-4e5a3fbcafcaa0cdaba351dfb307b0000179c832.tar.gz nextcloud-server-4e5a3fbcafcaa0cdaba351dfb307b0000179c832.zip |
- Fixed indentations.
- Fixed a bug in legacy.php: there was an error that was not checked for if the table 'fscache' did not exist in the database.
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/lib/db.php b/lib/db.php index c3ff481e19e..3ccd51737ae 100644 --- a/lib/db.php +++ b/lib/db.php @@ -943,95 +943,95 @@ class PDOStatementWrapper{ } } - private function tryFixSubstringLastArgumentDataForMSSQL($input) { - $query = $this->statement->queryString; - $pos = stripos ($query, 'SUBSTRING'); - - if ( $pos === false) { - return; - } - - try { - $newQuery = ''; - - $cArg = 0; - - $inSubstring = false; - - // Create new query - for ($i = 0; $i < strlen ($query); $i++) { - if ($inSubstring == false) { - // Defines when we should start inserting values - if (substr ($query, $i, 9) == 'SUBSTRING') { - $inSubstring = true; - } - } else { - // Defines when we should stop inserting values - if (substr ($query, $i, 1) == ')') { - $inSubstring = false; - } - } - - if (substr ($query, $i, 1) == '?') { - // We found a question mark - if ($inSubstring) { - $newQuery .= $input[$cArg]; - - // - // Remove from input array - // - array_splice ($input, $cArg, 1); - } else { - $newQuery .= substr ($query, $i, 1); - $cArg++; - } - } else { - $newQuery .= substr ($query, $i, 1); - } - } + private function tryFixSubstringLastArgumentDataForMSSQL($input) { + $query = $this->statement->queryString; + $pos = stripos ($query, 'SUBSTRING'); - // The global data we need - $name = OC_Config::getValue( "dbname", "owncloud" ); - $host = OC_Config::getValue( "dbhost", "" ); - $user = OC_Config::getValue( "dbuser", "" ); - $pass = OC_Config::getValue( "dbpassword", "" ); - if (strpos($host,':')) { - list($host, $port) = explode(':', $host, 2); - } else { - $port = false; - } - $opts = array(); + if ( $pos === false) { + return; + } - if ($port) { - $dsn = 'sqlsrv:Server='.$host.','.$port.';Database='.$name; - } else { - $dsn = 'sqlsrv:Server='.$host.';Database='.$name; - } + try { + $newQuery = ''; - $PDO = new PDO($dsn, $user, $pass, $opts); - $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $cArg = 0; - $this->statement = $PDO->prepare($newQuery); + $inSubstring = false; - $this->lastArguments = $input; - - return $input; - } catch (PDOException $e){ + // Create new query + for ($i = 0; $i < strlen ($query); $i++) { + if ($inSubstring == false) { + // Defines when we should start inserting values + if (substr ($query, $i, 9) == 'SUBSTRING') { + $inSubstring = true; + } + } else { + // Defines when we should stop inserting values + if (substr ($query, $i, 1) == ')') { + $inSubstring = false; + } + } + + if (substr ($query, $i, 1) == '?') { + // We found a question mark + if ($inSubstring) { + $newQuery .= $input[$cArg]; + + // + // Remove from input array + // + array_splice ($input, $cArg, 1); + } else { + $newQuery .= substr ($query, $i, 1); + $cArg++; + } + } else { + $newQuery .= substr ($query, $i, 1); + } + } + + // The global data we need + $name = OC_Config::getValue( "dbname", "owncloud" ); + $host = OC_Config::getValue( "dbhost", "" ); + $user = OC_Config::getValue( "dbuser", "" ); + $pass = OC_Config::getValue( "dbpassword", "" ); + if (strpos($host,':')) { + list($host, $port) = explode(':', $host, 2); + } else { + $port = false; + } + $opts = array(); + + if ($port) { + $dsn = 'sqlsrv:Server='.$host.','.$port.';Database='.$name; + } else { + $dsn = 'sqlsrv:Server='.$host.';Database='.$name; + } + + $PDO = new PDO($dsn, $user, $pass, $opts); + $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $this->statement = $PDO->prepare($newQuery); + + $this->lastArguments = $input; + + return $input; + } catch (PDOException $e){ $entry = 'PDO DB Error: "'.$e->getMessage().'"<br />'; $entry .= 'Offending command was: '.$this->statement->queryString .'<br />'; $entry .= 'Input parameters: ' .print_r($input, true).'<br />'; $entry .= 'Stack trace: ' .$e->getTraceAsString().'<br />'; OC_Log::write('core', $entry, OC_Log::FATAL); - OC_User::setUserId(null); + OC_User::setUserId(null); - // send http status 503 - header('HTTP/1.1 503 Service Temporarily Unavailable'); - header('Status: 503 Service Temporarily Unavailable'); - OC_Template::printErrorPage('Failed to connect to database'); - die ($entry); + // send http status 503 + header('HTTP/1.1 503 Service Temporarily Unavailable'); + header('Status: 503 Service Temporarily Unavailable'); + OC_Template::printErrorPage('Failed to connect to database'); + die ($entry); } - } + } /** * provide numRows |