2004-03-15 23:17:52 +01:00
|
|
|
<?PHP
|
|
|
|
|
2004-07-10 09:19:40 +02:00
|
|
|
// V4.50 6 July 2004
|
2004-03-15 23:17:52 +01:00
|
|
|
|
|
|
|
error_reporting(E_ALL);
|
2005-09-26 12:12:10 +02:00
|
|
|
include_once( "../adodb.inc.php" );
|
|
|
|
include_once( "../adodb-xmlschema.inc.php" );
|
2004-03-15 23:17:52 +01:00
|
|
|
|
|
|
|
// To build the schema, start by creating a normal ADOdb connection:
|
|
|
|
$db = ADONewConnection( 'mysql' );
|
|
|
|
$db->Connect( 'localhost', 'root', '', 'schematest' );
|
|
|
|
|
|
|
|
// To create a schema object and build the query array.
|
|
|
|
$schema = new adoSchema( $db );
|
|
|
|
|
|
|
|
// To upgrade an existing schema object, use the following
|
|
|
|
// To upgrade an existing database to the provided schema,
|
|
|
|
// uncomment the following line:
|
|
|
|
#$schema->upgradeSchema();
|
|
|
|
|
2004-08-02 10:30:47 +02:00
|
|
|
print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
|
2004-03-15 23:17:52 +01:00
|
|
|
// Build the SQL array
|
|
|
|
$sql = $schema->ParseSchema( "xmlschema.xml" );
|
|
|
|
|
|
|
|
print_r( $sql );
|
|
|
|
print "</pre>\n";
|
|
|
|
|
|
|
|
// Execute the SQL on the database
|
|
|
|
//$result = $schema->ExecuteSchema( $sql );
|
|
|
|
|
|
|
|
// Finally, clean up after the XML parser
|
|
|
|
// (PHP won't do this for you!)
|
|
|
|
//$schema->Destroy();
|
2004-07-10 09:19:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-26 12:12:10 +02:00
|
|
|
print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
|
2004-07-10 09:19:40 +02:00
|
|
|
|
2005-09-26 12:12:10 +02:00
|
|
|
$db2 = ADONewConnection('mssql');
|
|
|
|
$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");
|
2004-08-02 10:30:47 +02:00
|
|
|
|
2005-09-26 12:12:10 +02:00
|
|
|
$db2->Execute("drop table simple_table");
|
2004-08-02 10:30:47 +02:00
|
|
|
|
2004-07-10 09:19:40 +02:00
|
|
|
$schema = new adoSchema( $db2 );
|
|
|
|
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
|
|
|
|
|
|
|
|
print_r( $sql );
|
|
|
|
print "</pre>\n";
|
|
|
|
|
|
|
|
$db2->debug=1;
|
|
|
|
|
2005-09-26 12:12:10 +02:00
|
|
|
foreach ($sql as $s)
|
|
|
|
$db2->Execute($s);
|
2004-03-15 23:17:52 +01:00
|
|
|
?>
|