<?
require_once('adoxml.php');
$conn = & ADONewConnection('mysql');
$conn->Connect('localhost', 'dbusername', 'dbpassword', 'dbname');
$rs = $conn->Execute('select * from your_table');
//or if you want to use chached queries:
//$rs = $conn->CacheExecute(600,'select * from your_table');
$adoxml = new ADOXML();
//the include_pk var is a flag to determine whether primary key field should be included
//in xml source or not.
// Note: must be true for UpdateXML to work.
$adoxml->include_pk = true;
$xml = $adoxml->BuildXML($rs,'your_table');
//or we can build directly with a query:
//$xml = $adoxml->BuildXMLWithQuery('select * from your_table',$conn);
//say we want to connect to SQL Server:
$sqls =& ADONewConnection('odbc_mssql');
$dsn = "Driver={SQL Server};Server=your_sql_server;Database=database;";
$sqls->Connect($dsn,'sqlsusername','sqlspassword');
//if we want to insert our xml into sql server:
//we use the sqlserver connection object: $sqls
$adoxml->InsertXML($xml,$sqls,'your_table');
//we can also modify the xml here as we see fit
//and then later we can update the changes made to xml in the database:
//Note: The UpdateXML function assumes the first field in the XML source is the primary key field.
// You can generate XML String with primary key by setting class var include_pk to true
$adoxml->UpdateXML($xml,$sqls,'your_table');
//Functions to be added to ADOXML
//delete function
//function to automatically read and execute sql files
?>
|