diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-02-25 22:49:55 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-07-21 23:17:37 +0200 |
commit | 58991150ab17846640907d43a6d4b0ff502d4986 (patch) | |
tree | 68b840c85a9b099872510b6adc6f420273ebbd80 /lib/db.php | |
parent | 1d5d23a1de5a490595d8bb7ea81b8bda48b8feeb (diff) | |
download | nextcloud-server-58991150ab17846640907d43a6d4b0ff502d4986.tar.gz nextcloud-server-58991150ab17846640907d43a6d4b0ff502d4986.zip |
Move query statement fixup handling to Connection wrapper
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/lib/db.php b/lib/db.php index 4451f813905..0ad8a9b35d8 100644 --- a/lib/db.php +++ b/lib/db.php @@ -213,11 +213,6 @@ class OC_DB { * SQL query via Doctrine prepare(), needs to be execute()'d! */ static public function prepare( $query , $limit = null, $offset = null, $isManipulation = null) { - // Optimize the query - $query = self::processQuery( $query ); - if(OC_Config::getValue( "log_query", false)) { - OC_Log::write('core', 'DB prepare : '.$query, OC_Log::DEBUG); - } self::connect(); if ($isManipulation === null) { @@ -449,49 +444,6 @@ class OC_DB { } /** - * @brief does minor changes to query - * @param string $query Query string - * @return string corrected query string - * - * This function replaces *PREFIX* with the value of $CONFIG_DBTABLEPREFIX - * and replaces the ` with ' or " according to the database driver. - */ - private static function processQuery( $query ) { - self::connect(); - // We need Database type - if(is_null(self::$type)) { - self::$type=OC_Config::getValue( "dbtype", "sqlite" ); - } - $type = self::$type; - - // differences in escaping of table names ('`' for mysql) and getting the current timestamp - if( $type == 'sqlite' || $type == 'sqlite3' ) { - $query = str_replace( '`', '"', $query ); - $query = str_ireplace( 'NOW()', 'datetime(\'now\')', $query ); - $query = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $query ); - } elseif( $type == 'pgsql' ) { - $query = str_replace( '`', '"', $query ); - $query = str_ireplace( 'UNIX_TIMESTAMP()', 'cast(extract(epoch from current_timestamp) as integer)', - $query ); - } elseif( $type == 'oci' ) { - $query = str_replace( '`', '"', $query ); - $query = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $query ); - $query = str_ireplace( 'UNIX_TIMESTAMP()', "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400", $query ); - }elseif( $type == 'mssql' ) { - $query = preg_replace( "/\`(.*?)`/", "[$1]", $query ); - $query = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $query ); - $query = str_replace( 'LENGTH(', 'LEN(', $query ); - $query = str_replace( 'SUBSTR(', 'SUBSTRING(', $query ); - $query = str_ireplace( 'UNIX_TIMESTAMP()', 'DATEDIFF(second,{d \'1970-01-01\'},GETDATE())', $query ); - } - - return $query; - } - - return $query; - } - - /** * @brief drop a table * @param string $tableName the table to drop */ |