示例#1
0
 function buildChangesetDefinition()
 {
     if (!file_exists($this->file_changes)) {
         $this->_logError('changes file not found: ' . $this->file_changes);
         return false;
     }
     $this->aChanges = $this->oCache->get($this->file_changes);
     if (!$this->aChanges) {
         $this->oLogger->logOnly('changeset definition from cache FALSE');
         $this->aChanges = $this->oSchema->parseChangesetDefinitionFile($this->file_changes);
         if ($this->_isPearError($this->aChanges, 'failed to parse changeset (' . $this->file_changes . ')')) {
             return false;
         }
         // On-the fly cache writing disabled
         //$this->oCache->save($this->aChanges, $this->file_changes);
     } else {
         $this->oLogger->logOnly('changeset definition from cache TRUE');
     }
     $this->_logOnly('successfully parsed the changeset');
     $this->_logOnly('changeset name: ' . $this->aChanges['name']);
     $this->_logOnly('changeset version: ' . $this->aChanges['version']);
     $this->_logOnly('changeset comments: ' . $this->aChanges['comments']);
     $this->_logOnly($this->aDefinitionNew['version'] == $this->aChanges['version'] ? 'schema and changeset versions match' : 'hmmm.. schema and changeset versions don\'t match');
     $this->_logOnly($this->aChanges['constructive'] ? 'constructive changes found' : 'constructive changes not found');
     $this->_logOnly($this->aChanges['destructive'] ? 'destructive changes found' : 'destructive changes not found');
     return true;
 }
示例#2
0
 /**
  * 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;
 }