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


PHP PHPWS_DB::touchDB方法代码示例

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


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

示例1: import

 /**
  * Imports a SQL dump into the database.
  * This function can not be called statically.
  * @returns True if successful, false if not successful and report_errors = false or
  *               Error object if report_errors = true
  */
 public static function import($text, $report_errors = true)
 {
     PHPWS_DB::touchDB();
     // first_import makes sure at least one query was completed
     // successfully
     $first_import = false;
     $sqlArray = PHPWS_Text::sentence($text);
     $error = false;
     foreach ($sqlArray as $sqlRow) {
         if (empty($sqlRow) || preg_match("/^[^\\w\\d\\s\\(\\)]/i", $sqlRow)) {
             continue;
         }
         $sqlCommand[] = $sqlRow;
         if (preg_match("/;\$/", $sqlRow)) {
             $query = implode(' ', $sqlCommand);
             $sqlCommand = array();
             if (!DB_ALLOW_TABLE_INDEX && preg_match('/^create index/i', $query)) {
                 continue;
             }
             PHPWS_DB::homogenize($query);
             $result = PHPWS_DB::query($query);
             if (DB::isError($result)) {
                 if ($report_errors) {
                     return $result;
                 } else {
                     PHPWS_Error::log($result);
                     $error = true;
                 }
             }
             $first_import = true;
         }
     }
     if (!$first_import) {
         if ($report_errors) {
             return PHPWS_Error::get(PHPWS_DB_IMPORT_FAILED, 'core', 'PHPWS_DB::import');
         } else {
             PHPWS_Error::log(PHPWS_DB_IMPORT_FAILED, 'core', 'PHPWS_DB::import');
             $error = true;
         }
     }
     if ($error) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:jeffrafter,项目名称:InternshipInventory,代码行数:52,代码来源:SubselectDatabase.php

示例2: export

 public function export($structure = true, $contents = true)
 {
     PHPWS_DB::touchDB();
     $table = $this->addPrefix($this->tables[0]);
     if ($structure == true) {
         $GLOBALS['PHPWS_DB']['connection']->loadModule('Reverse', null, true);
         $columns = $GLOBALS['PHPWS_DB']['connection']->tableInfo($table);
         $column_info = $this->parseColumns($columns);
         $index = $this->getIndex();
         $sql[] = "CREATE TABLE {$table} ( " . implode(', ', $column_info['parameters']) . ' );';
         if (isset($column_info['index'])) {
             $sql = array_merge($sql, $column_info['index']);
         }
     }
     if ($contents == true) {
         if ($rows = $this->select()) {
             if (PHPWS_Error::isError($rows)) {
                 return $rows;
             }
             foreach ($rows as $dataRow) {
                 foreach ($dataRow as $key => $value) {
                     $allKeys[] = $key;
                     $allValues[] = PHPWS_DB::escape($value);
                 }
                 $sql[] = "INSERT INTO {$table} (" . implode(', ', $allKeys) . ') VALUES (' . implode(', ', $allValues) . ');';
                 $allKeys = $allValues = array();
             }
         }
     }
     if (!empty($sql)) {
         return implode("\n", $sql);
     } else {
         return null;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:35,代码来源:PHPWS_DB.php


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