<?php
 
 
require_once ("include/xmldb.php");
 
require_once ("include/xmldb_query.php");
 
 
 
$Table=new XMLTable("dbtest","mytable",".");
 
$records=$Table->GetRecords();
 
 
 
$fields[0]['name']="id";
 
$fields[0]['primarykey']=1;
 
$fields[0]['defaultvalue']=null;
 
$fields[0]['type']="string";
 
$fields[0]['extra']="autoincrement";
 
 
$fields[1]['name']="stringfield";
 
$fields[1]['primarykey']=0;
 
$fields[1]['defaultvalue']="the name";
 
$fields[1]['type']="string";
 
 
$fields[2]['name']="intfield";
 
$fields[2]['type']="int";
 
 
//---create xml database---
 
if (!xmldatabaseexists("dbtest","."))
 
{
 
    $err=createxmldatabase("dbtest",".");
 
    echo $err."<br />";
 
}
 
if (!xmltableexists("dbtest","mytable","."))
 
{
 
//---create xml table---
 
    $err=createxmltable("dbtest","mytable",$fields,".");
 
    echo $err;
 
}
 
if (!$records || count($records) < 5)
 
{
 
    //---insert new record
 
    $vals['stringfield']="this is string value";
 
    $vals['textfield']="this is text value";
 
    $recordinsert=$Table->InsertRecord($vals);
 
    $records=$Table->GetRecords();
 
}
 
 
echo "<pre>contents \"dbtest/mytable.php\"\n";
 
echo(htmlspecialchars(file_get_contents("dbtest/mytable.php")));
 
echo "</pre>";
 
 
 
//print records
 
echo "<pre>\$Table->GetRecords();\n";
 
print_r($records);
 
echo "</pre>";
 
 
if (is_array($records))
 
{
 
    $query="SELECT * FROM mytable ORDER BY id DESC LIMIT 1,5";
 
    $DB=new XMLDatabase("dbtest",".");
 
    $records=$DB->query($query);
 
    echo "<pre>";
 
    echo "\$DB->query(\"$query\") :\n";
 
    print_r($records);
 
    echo "</pre>";
 
}
 
?> 
 
 |