I am writing a new application in PHP which will be released to the public as a commercial application. Up to this point, my experience has been with MySQL databases within PHP.
The end user is responsible for providing the database functionality and the PHP application will simply connect to it and use it.
My question is, as I do not know what database the user will be using, what way do I go about supporting this in PHP?
The questions I have are:
-
Is ODBC the right way? I refer to ODBC below but if ODBC is not the right method to use, the same questions apply for whatever is the suggested method.
-
Do I lose any functionality/features using ODBC functions over the MySQL equivalents within PHP?
-
Is there anything security related I need to keep in mind? Eg I have used mysql_real_escape_string() in previous applications. What is the ODBC equivalent (is it even needed?)
-
I assume PHP can connect to a MySQL database using ODBC? Does MySQL need configured in some way to allow this?
-
Performance wise, is ODBC acceptable?
For support and performance, your best option would probably be PDO (PHP Database Object). This is core to PHP and supports all the main DB systems, will natively handle escaping strings and so on.
To stay agnostic, you can’t use MySQL only things, e.g. LIMIT add that’s not supported with all SQL databases.
But having said that, check first. If the client has a noSQL database, or uses Amazon with unique connection strings (for example) then you’re in trouble.