I'm interested in the question, Is it possible to replace MySQL database with JSON files for WordPress? Let me explain what I mean. We have 12 standard tables after WordPress installation. We can write each of them into separate JSON file so that each file will be named as its respective table e.g. wp_posts.json, wp_options.json etc. And each file will contain table rows like
wp_options.json
"1":{"option_name":"siteurl","option_value":"http://localhost","autoload":"yes"},
"2":{"option_name":"home","option_value":"http://localhost","autoload":"yes"},
...
or some other format
So the main question is, How to listen or intercept every SQL-query made by WordPress and give back the right result from the right JSON file? And write data into JSON file if the SQL-query is UPDATE
or INSERT
For example if SQL-query from WordPress is like
SELECT siteurl FROM wp_options WHERE id = 1
we read the wp_options.json
, find the row no. 1 and give back the option_value
As I can understand, all queries are being handled in the wp-includes/wp-db.php file but I don't know what should I start from. Could you at least describe the general steps or maybe there is a tutorial in details or plugin for the purpose?
Or maybe we can listen MySQL host and port?