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


PHP MDB2_Schema::createTable方法代码示例

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


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

示例1: createTable

 /**
  * A method for creating a table from the currently parsed database XML schema file.
  *
  * @param string $table The name of the table to create, excluding table prefix.
  * @param Date $oDate An optional date for creating split tables. Will use current
  *                    date if the date is required for creation, but not supplied.
  * @param boolean $suppressTempTableError When true, do not produce an error debugging
  *                                        message if trying to create a temporary table
  *                                        that already exists.
  * @return mixed The name of the table created, or false if the table was not able
  *               to be created.
  */
 function createTable($table, $oDate = null, $suppressTempTableError = false)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     if (!$this->_checkInit()) {
         return false;
     }
     // Does the table exist?
     if (!is_array($this->aDefinition['tables'][$table])) {
         OA::debug('Cannot find table ' . $table . ' in the XML schema file', PEAR_LOG_ERR);
         return false;
     }
     $tableName = $this->_generateTableName($table, $oDate);
     // Prepare the options array
     $aOptions = array();
     if ($this->temporary) {
         $aOptions['temporary'] = true;
     }
     $aOptions['type'] = $aConf['table']['type'];
     // Merge any primary keys into the options array
     if (isset($this->aDefinition['tables'][$table]['indexes'])) {
         if (is_array($this->aDefinition['tables'][$table]['indexes'])) {
             foreach ($this->aDefinition['tables'][$table]['indexes'] as $key => $aIndex) {
                 if (isset($aIndex['primary']) && $aIndex['primary']) {
                     $aOptions['primary'] = $aIndex['fields'];
                     $indexName = $tableName . '_pkey';
                 } else {
                     // Eventually strip the leading table name prefix from the index and
                     // add the currently generated table name. This should ensure that
                     // index names are unique database-wide, required at least by PgSQL
                     //
                     // The index name is cut at 64 chars
                     //
                     $indexName = $this->_generateIndexName($tableName, $key);
                 }
                 // Does the index name need to be udpated to match either
                 // the prefixed table name, or the the split table name, or
                 // simply it has a wrong name in the xml definition?
                 if ($key != $indexName) {
                     // Eventually strip the hardcoded leading table name and add the
                     // correct prefix to the index name
                     $this->aDefinition['tables'][$table]['indexes'][$indexName] = $this->aDefinition['tables'][$table]['indexes'][$key];
                     unset($this->aDefinition['tables'][$table]['indexes'][$key]);
                 }
             }
         }
     }
     // Create the table
     OA::debug('Creating the ' . $tableName . ' table', PEAR_LOG_DEBUG);
     OA::disableErrorHandling();
     OA_DB::setCaseSensitive();
     $result = $this->oSchema->createTable($tableName, $this->aDefinition['tables'][$table], false, $aOptions);
     OA_DB::disableCaseSensitive();
     OA::enableErrorHandling();
     if (PEAR::isError($result) || !$result) {
         $showError = true;
         if ($this->temporary && $suppressTempTableError) {
             $showError = false;
         }
         if ($showError) {
             OA::debug('Unable to create the table ' . $table, PEAR_LOG_ERR);
             if (PEAR::isError($result)) {
                 OA::debug($result->getUserInfo(), PEAR_LOG_ERR);
             }
         }
         return false;
     }
     return $tableName;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:80,代码来源:Table.php


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