I’ve been wanting to build multi-database apps for a while and I still can’t find anything about how to go about it.
All I would like to know is the best way to handle SQLite and MySQL queries. Do I need to have an IF statement with two different queries for each query I want to run?
Or is there an easy way to convert a MySQL statement into SQLite?
Use PHP’s PDO.
All you need to do is change the connection string and you can connect to different databases. As long as your SQL isn’t written using functions specific to a particular database, it will just work with these databases:
It supports all the functions you want as well as many built in goodies preventing injection attacks and a bunch more.
Edit: Some nice links for further reading as suggested by eldbiz
http://php.net/manual/en/book.pdo.php
http://www.php.net/manual/en/ref.pdo-sqlite.php
http://www.php.net/manual/en/ref.pdo-mysql.php