PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/include/adodb/tests/test-xmlschema.php

https://github.com/radicaldesigns/amp
PHP | 54 lines | 23 code | 18 blank | 13 comment | 2 complexity | c64f9923dda687bb398a44ceb708197a MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?PHP
  2. // V4.50 6 July 2004
  3. error_reporting(E_ALL);
  4. include_once( "../adodb.inc.php" );
  5. include_once( "../adodb-xmlschema03.inc.php" );
  6. // To build the schema, start by creating a normal ADOdb connection:
  7. $db = ADONewConnection( 'mysql' );
  8. $db->Connect( 'localhost', 'root', '', 'test' ) || die('fail connect1');
  9. // To create a schema object and build the query array.
  10. $schema = new adoSchema( $db );
  11. // To upgrade an existing schema object, use the following
  12. // To upgrade an existing database to the provided schema,
  13. // uncomment the following line:
  14. #$schema->upgradeSchema();
  15. print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
  16. // Build the SQL array
  17. $sql = $schema->ParseSchema( "xmlschema.xml" );
  18. var_dump( $sql );
  19. print "</pre>\n";
  20. // Execute the SQL on the database
  21. //$result = $schema->ExecuteSchema( $sql );
  22. // Finally, clean up after the XML parser
  23. // (PHP won't do this for you!)
  24. //$schema->Destroy();
  25. print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
  26. $db2 = ADONewConnection('mssql');
  27. $db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");
  28. $db2->Execute("drop table simple_table");
  29. $schema = new adoSchema( $db2 );
  30. $sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
  31. print_r( $sql );
  32. print "</pre>\n";
  33. $db2->debug=1;
  34. foreach ($sql as $s)
  35. $db2->Execute($s);
  36. ?>