I need a custom PHP script that can duplicate the basic functions of MySQL using XML files. The purpose is to test MySQL queries on servers that do not have MySQL installed.
The script should use PHP's built-in XML Parser to read and update files holding the table data. Each table should be stored in a separate XML file. Another file can be used to hold the table schema, if that would be easier.
Each database should be stored in a separate folder, which holds all of the XML and other files for that database.
More advanced features, such as user privileges and indexes are not necessary. The main purpose is just to run queries to test them.
The script should read, interpret, and execute the following components of MySQL queries:
- Select statements (column names and * wildcards)
- Update statements
- Insert statements
- Replace statements
- Delete statements
- Where clauses (with AND, OR, NOT, IN, =, <, >, <=, >=, !=, <> operators)
- Order by clauses (ASC or DESC)
- Group by clauses
- Table joins (left, right, inner, outer)
- Create database
- Drop database
- Create table
- Alter table
- Drop table
The Alter Table queries should be able to update a table's schema. Queries to add indexes and other features not used in this script should be ignored, but not return errors.
The script should be able to run the following MySQL functions within queries. In most cases, a similar function is built into PHP so it can simply use PHP to get the result.
- Basic math such as: Update table set num=num+1;
The script should have the following functions that simulate the MySQL functions in PHP.
run_query() - Simulates the mysql_query() function in PHP. Should return a resource or boolean, depending on the type of query.
choose_db() - Simulates mysql_select_db() to select the database. Since the script is just for testing, connecting and logging into the database is not necessary.
query_fetch_array() - Simulates mysql_fetch_array()
query_fetch_row() - Simulates mysql_fetch_row()
count_rows() - Simulates mysql_num_rows()
get_result() - Simulates mysql_result()
get_error() - Returns any obvious syntax errors on the last query submitted to the run_query() function.
I would need exclusive ownership and copyright of the code for this script. Please let me know if you have any questions or need any clarification.