PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Johan De Klerk   ADOXML   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: an example
Convert between SQL query results and XML files
Author: By
Last change:
Date: 19 years ago
Size: 1,531 bytes


Class file image Download

$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;";

//if we want to insert our xml into sql server:
//we use the sqlserver connection object: $sqls


//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


//Functions to be added to ADOXML
//delete function
//function to automatically read and execute sql files