irm-1.6-b3/MDB/Manager.php
/**
     * Compare the correspondent files of two versions of a database schema
     * definition: the previously installed and the one that defines the schema
     * that is meant to update the database.
     * If the specified previous definition file does not exist, this function
     * will create the database from the definition specified in the current
     * schema file.
     * If both files exist, the function assumes that the database was previously
     * installed based on the previous schema file and will update it by just
     * applying the changes.
     * If this function succeeds, the contents of the current schema file are
     * copied to replace the previous schema file contents. Any subsequent schema
     * changes should only be done on the file specified by the $current_schema_file
     * to let this function make a consistent evaluation of the exact changes that
     * need to be applied.
     *
     * @param string $current_schema_file name of the updated database schema
     * definition file.
     * @param string $previous_schema_file name the previously installed database
     * schema definition file.
     * @param array $variables an associative array that is passed to the argument
     * of the same name to the parseDatabaseDefinitionFile function. (there third
     * param)
     * @return mixed MDB_OK on success, or a MDB error object
     * @access public
     */
Compare the correspondent files of two versions of a database schema
definition: the previously installed and the one that defines the schema
that is meant to update the database.
If the specified previous definition file does not exist, this function
will create the database from the definition specified in the current
schema file.
If both files exist, the function assumes that the database was previously
installed based on the previous schema file and will update it by just
applying the changes.
If this function succeeds, the contents of the current schema file are
copied to replace the previous schema file contents. Any subsequent schema
changes should only be done on the file specified by the $current_schema_file
to let this function make a consistent evaluation of the exact changes that
need to be applied.

@param string $current_schema_file name of the updated database schema
definition file.
@param string $previous_schema_file name the previously installed database
schema definition file.
@param array $variables an associative array that is passed to the argument
of the same name to the parseDatabaseDefinitionFile function. (there third
param)
@return mixed MDB_OK on success, or a MDB error object
@access public
Compare the correspondent files of two versions of a database schema definition : the previously installed and the one that defines the schema that is meant to update the database . If the specified previous definition file does not exist this function will create the database from the definition specified in the current schema file . If both files exist the function assumes that the database was previously installed based on the previous schema file and will update it by just applying the changes . If this function succeeds the contents of the current schema file are copied to replace the previous schema file contents . Any subsequent schema changes should only be done on the file specified by the $current_schema_file to let this function make a consistent evaluation of the exact changes that need to be applied . @param string $current_schema_file name of the updated database schema definition file . @param string $previous_schema_file name the previously installed database schema definition file . @param array $variables an associative array that is passed to the argument of the same name to the parseDatabaseDefinitionFile function . ( there third param ) @return mixed MDB_OK on success or a MDB error object @access public
function updateDatabase($current_schema_file, $previous_schema_file = FALSE, $variables = array())
    {
        $database_definition = $this->parseDatabaseDefinitionFile($current_schema_file,
            $variables, $this->options['fail_on_invalid_names']);
        if(MDB::isError($database_definition)) {
            return($database_definition);
        }
        $this->database_definition = $database_definition;
        $copy = 0;
        if($previous_schema_file && file_exists($previous_schema_file)) {
            $previous_definition = $this->parseDatabaseDefinitionFile($previous_schema_file, $variables, 0);
            if(MDB::isError($previous_definition)) {
                return($previous_definition);
            }
            $changes = $this->_compareDefinitions($previous_definition);
            if(MDB::isError($changes)) {
                return($changes);
            }
            if(isset($changes) && is_array($changes)) {
                $result = $this->_alterDatabase($previous_definition, $changes);
                if(MDB::isError($result)) {
                    return($result);
                }
                $copy = 1;
                if($this->options['debug']) {
                    $result = $this->_debugDatabaseChanges($changes);
                    if(MDB::isError($result)) {
                        return($result);
                    }
                }
            }
        } else {
            $result = $this->_createDatabase();
            if(MDB::isError($result)) {
                return($result);
            }
            $copy = 1;
        }
        if($copy && $previous_schema_file && !copy($current_schema_file, $previous_schema_file)) {
            return($this->raiseError(MDB_ERROR_MANAGER, NULL, NULL,
                'Could not copy the new database definition file to the current file'));
        }
        return(MDB_OK);
    }
function updateDatabase ( $ current_schema_file , $ previous_schema_file = FALSE , $ variables = array ( ) ) { $ database_definition = $ this -> parseDatabaseDefinitionFile ( $ current_schema_file , $ variables , $ this -> options [ 'fail_on_invalid_names' ] ) ; if ( MDB :: isError ( $ database_definition ) ) { return ( $ database_definition ) ; } $ this -> database_definition = $ database_definition ; $ copy = 0 ; if ( $ previous_schema_file && file_exists ( $ previous_schema_file ) ) { $ previous_definition = $ this -> parseDatabaseDefinitionFile ( $ previous_schema_file , $ variables , 0 ) ; if ( MDB :: isError ( $ previous_definition ) ) { return ( $ previous_definition ) ; } $ changes = $ this -> _compareDefinitions ( $ previous_definition ) ; if ( MDB :: isError ( $ changes ) ) { return ( $ changes ) ; } if ( isset ( $ changes ) && is_array ( $ changes ) ) { $ result = $ this -> _alterDatabase ( $ previous_definition , $ changes ) ; if ( MDB :: isError ( $ result ) ) { return ( $ result ) ; } $ copy = 1 ; if ( $ this -> options [ 'debug' ] ) { $ result = $ this -> _debugDatabaseChanges ( $ changes ) ; if ( MDB :: isError ( $ result ) ) { return ( $ result ) ; } } } } else { $ result = $ this -> _createDatabase ( ) ; if ( MDB :: isError ( $ result ) ) { return ( $ result ) ; } $ copy = 1 ; } if ( $ copy && $ previous_schema_file && ! copy ( $ current_schema_file , $ previous_schema_file ) ) { return ( $ this -> raiseError ( MDB_ERROR_MANAGER , NULL , NULL , 'Could not copy the new database definition file to the current file' ) ) ; } return ( MDB_OK ) ; }
Compare the correspondent files of two versions of a database schema
 definition: the previously installed and the one that defines the schema
 that is meant to update the database.
Compare the correspondent files of two versions of a database schema definition : the previously installed and the one that defines the schema that is meant to update the database .
/*
        $this->expectError(MDB_ERROR_UNSUPPORTED);
        $databases = $this->database->listDatabases();
        $this->popExpect();
        if((MDB::isError($databases) || (is_array($databases) && in_array($this->database_definition['name'], $databases)))
            && $previous_schema_file && file_exists($previous_schema_file))
        {
*/