当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_DB::type方法代码示例

本文整理汇总了PHP中OC_DB::type方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_DB::type方法的具体用法?PHP OC_DB::type怎么用?PHP OC_DB::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_DB的用法示例。


在下文中一共展示了OC_DB::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processQuery

 /**
  * @brief does minor chages to query
  * @param $query Query string
  * @returns corrected query string
  *
  * This function replaces *PREFIX* with the value of $CONFIG_DBTABLEPREFIX
  * and replaces the ` woth ' or " according to the database driver.
  */
 private static function processQuery($query)
 {
     self::connect();
     // We need Database type and table prefix
     if (is_null(self::$type)) {
         self::$type = OC_Config::getValue("dbtype", "sqlite");
     }
     $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
     if ($type == 'sqlite' || $type == 'sqlite3') {
         $query = str_replace('`', '"', $query);
         $query = str_replace('NOW()', 'datetime(\'now\')', $query);
         $query = str_replace('now()', 'datetime(\'now\')', $query);
     } elseif ($type == 'mysql') {
         $query = str_replace('NOW()', 'CURRENT_TIMESTAMP', $query);
         $query = str_replace('now()', 'CURRENT_TIMESTAMP', $query);
     } elseif ($type == 'pgsql') {
         $query = str_replace('`', '"', $query);
         $query = str_replace('NOW()', 'CURRENT_TIMESTAMP', $query);
         $query = str_replace('now()', 'CURRENT_TIMESTAMP', $query);
     }
     // replace table name prefix
     $query = str_replace('*PREFIX*', $prefix, $query);
     return $query;
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:37,代码来源:db.php

示例2: processQuery

 /**
  * @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 and table prefix
     if (is_null(self::$type)) {
         self::$type = OC_Config::getValue("dbtype", "sqlite");
     }
     $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
     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))-TO_DATE(\'1970101000000\',\'YYYYMMDDHH24MiSS\'))*24*3600', $query);
     } elseif ($type == 'mssql') {
         $query = preg_replace("/\\`(.*?)`/", "[\$1]", $query);
         $query = str_replace('NOW()', 'CURRENT_TIMESTAMP', $query);
         $query = str_replace('now()', 'CURRENT_TIMESTAMP', $query);
         $query = str_replace('LENGTH(', 'LEN(', $query);
         $query = str_replace('SUBSTR(', 'SUBSTRING(', $query);
         $query = self::fixLimitClauseForMSSQL($query);
     }
     // replace table name prefix
     $query = str_replace('*PREFIX*', $prefix, $query);
     return $query;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:44,代码来源:db.php


注:本文中的OC_DB::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。