adoSchema::ParseSchemaFile PHP Method

ParseSchemaFile() public method

Call this method to load the specified schema from a file (see the DTD for the proper format) and generate the SQL necessary to create the database described by the schema.
Deprecation: Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
public ParseSchemaFile ( $filename, boolean $returnSchema = FALSE ) : array
$returnSchema boolean Return schema rather than parsing.
return array Array of SQL queries, ready to execute.
    function ParseSchemaFile($filename, $returnSchema = FALSE)
    {
        // Open the file
        if (!($fp = fopen($filename, 'r'))) {
            // die( 'Unable to open file' );
            return FALSE;
        }
        // do version detection here
        if ($this->SchemaFileVersion($filename) != $this->schemaVersion) {
            return FALSE;
        }
        if ($returnSchema) {
            $xmlstring = '';
            while ($data = fread($fp, 100000)) {
                $xmlstring .= $data;
            }
            return $xmlstring;
        }
        $this->success = 2;
        $xmlParser = $this->create_parser();
        // Process the file
        while ($data = fread($fp, 4096)) {
            if (!xml_parse($xmlParser, $data, feof($fp))) {
                die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xmlParser)), xml_get_current_line_number($xmlParser)));
            }
        }
        xml_parser_free($xmlParser);
        return $this->sqlArray;
    }