3 Home
Shikiryu edited this page 2019-10-21 09:36:23 +02:00

PHP XML Database Class

The goal of this project is to get a PHP class managing a database in XML format as it would be in MySQL (but with less options obviously)


Database Format

<?xml version="1.0" encoding="utf-8"?>
<Database>
    <table name="table1">
        <item id="clock">
            <visibility>false</visibility>
            <x>950</x>
            <y>42</y>
        </item>
        <item id="weather">
            <visibility>true</visibility>
            <city>Paris</city>
            <x>605</x>
            <y>648</y>
        </item>
    </table>
    <table name="table2">
        <item id="clockAdvanced">
            <visibility>false</visibility>
            <x>80</x>
            <y>10</y>
            <fontFamily>Times New Roman, serif</fontFamily>
            <fontSize>20px</fontSize>
            <format>%A %d %B %Y - %H:%M:%S</format>
            <color>#000</color>
	</item>
    </table>
</Database>

As you can see, the XML contains only one Database but an infinite (well, not that much ;) ) number of Tables with a unique name and in which you can have items that could be compared to rows in MySQL. The differences are :

  • In a table, you can have items with different attributes as you can see in table1
  • Attributes can't have different formats (for now). Everything is a @string@. Of course, you can convert them later.
  • You can move items from table to table! You could even move them to a precise location into your file!

"SQL" command syntax

  • Data definition (like Create Database, Drop Database, Create Table, Drop Table )
  • Data manipulation (like Insert, Delete, Update, Select, Move (experimental, only with XMLDB !) )