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


PHP MDB2_Schema::parseDatabaseDefinitionFile方法代码示例

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


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

示例1: init

 /**
  * A method to initialise the class by parsing a database XML schema file, so that
  * the class will be ready to create/drop tables for the supplied schema.
  *
  * @todo Better handling of cache files
  *
  * @param string $file     The name of the database XML schema file to parse for
  *                         the table definitions.
  * @param bool   $useCache If true definitions are loaded from the cache file
  * @return boolean True if the class was initialised correctly, false otherwise.
  */
 function init($file, $useCache = true)
 {
     // Ensure that the schema XML file can be read
     if (!is_readable($file)) {
         OA::debug('Unable to read the database XML schema file: ' . $file, PEAR_LOG_ERR);
         return false;
     }
     // Create an instance of MDB2_Schema to parse the schema file
     $options = array('force_defaults' => false);
     $this->oSchema =& MDB2_Schema::factory($this->oDbh, $options);
     if ($useCache) {
         $oCache = new OA_DB_XmlCache();
         $this->aDefinition = $oCache->get($file);
         $this->cached_definition = true;
     } else {
         $this->aDefinition = false;
     }
     if (!$this->aDefinition) {
         $this->cached_definition = false;
         // Parse the schema file
         $this->aDefinition = $this->oSchema->parseDatabaseDefinitionFile($file);
         if (PEAR::isError($this->aDefinition)) {
             OA::debug('Error parsing the database XML schema file: ' . $file, PEAR_LOG_ERR);
             return false;
         }
         // On-the fly cache writing disabled
         //if ($useCache) {
         //    $oCache->save($this->aDefinition, $file);
         //}
     }
     return true;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:43,代码来源:Table.php

示例2: removeDBStructure

 /**
  * remove all tables defined in a database structure xml file
  * @param string $file the xml file describing the tables
  */
 public static function removeDBStructure($file)
 {
     $CONFIG_DBNAME = OC_Config::getValue("dbname", "owncloud");
     $CONFIG_DBTABLEPREFIX = OC_Config::getValue("dbtableprefix", "oc_");
     self::connectScheme();
     // read file
     $content = file_get_contents($file);
     // Make changes and save them to a temporary file
     $file2 = tempnam(get_temp_dir(), 'oc_db_scheme_');
     $content = str_replace('*dbname*', $CONFIG_DBNAME, $content);
     $content = str_replace('*dbprefix*', $CONFIG_DBTABLEPREFIX, $content);
     file_put_contents($file2, $content);
     // get the tables
     $definition = self::$schema->parseDatabaseDefinitionFile($file2);
     // Delete our temporary file
     unlink($file2);
     $tables = array_keys($definition['tables']);
     foreach ($tables as $table) {
         self::dropTable($table);
     }
 }
开发者ID:ryanshoover,项目名称:core,代码行数:25,代码来源:db.php


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