File: test-xmlschema.php

package info (click to toggle)
libphp-adodb 5.15-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 3,440 kB
  • ctags: 10,457
  • sloc: php: 34,120; xml: 117; makefile: 34; sql: 32; sh: 22
file content (54 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?PHP

// V4.50 6 July 2004

error_reporting(E_ALL);
include_once( "../adodb.inc.php" );
include_once( "../adodb-xmlschema03.inc.php" );

// To build the schema, start by creating a normal ADOdb connection:
$db = ADONewConnection( 'mysql' );
$db->Connect( 'localhost', 'root', '', 'test' ) || die('fail connect1');

// 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();

print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
// Build the SQL array
$sql = $schema->ParseSchema( "xmlschema.xml" );

var_dump( $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();



print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";

$db2 = ADONewConnection('mssql');
$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");

$db2->Execute("drop table simple_table");

$schema = new adoSchema( $db2 );
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );

print_r( $sql );
print "</pre>\n";

$db2->debug=1;

foreach ($sql as $s)
$db2->Execute($s);
?>