adoSchema::ParseSchema PHP Method

ParseSchema() public method

Call this method to load the specified schema (see the DTD for the proper format) from the filesystem and generate the SQL necessary to create the database described.
See also: ParseSchemaString()
public ParseSchema ( $filename, boolean $returnSchema = FALSE ) : array
$returnSchema boolean Return schema rather than parsing.
return array Array of SQL queries, ready to execute
    function ParseSchema($filename, $returnSchema = FALSE)
    {
        return $this->ParseSchemaString($this->ConvertSchemaFile($filename), $returnSchema);
    }

Usage Example

Example #1
0
function create_table($schemaFile, $prefix, $db, $drop = true)
{
    $result = array();
    $schema = new adoSchema($db);
    $schema->setPrefix($prefix);
    $sql = $schema->ParseSchema($schemaFile);
    $dbTable = $schema->obj;
    $adoDB = $schema->db;
    $stmt = sprintf($adoDB->_dropSeqSQL, $dbTable->name);
    $dropresult = true;
    if ($drop) {
        $ok = $db->Execute($stmt);
        if (!$ok) {
            $dropresult = false;
        }
        $schema = new adoSchema($db);
        $schema->setPrefix($prefix);
        $sql = $schema->ParseSchema($schemaFile);
    }
    $result = $schema->ExecuteSchema($sql);
    ob_start();
    print_r($sql);
    $sql_r = ob_get_contents();
    ob_end_clean();
    return array('result' => $result, 'sql' => $sql_r);
}
All Usage Examples Of adoSchema::ParseSchema