On Thu, Jan 6, 2011 at 02:52, Miriam Natanzon <miriamna...@gmail.com> wrote:
> Hi,
> I want to build an internal module for common DB-involved tasks: starting
> with connection, simple queries and go on to multiple pages of results and
> connecting tables and so on.
> We are currently working with MySQL but maybe in the future we'll add use of
> MSSQL (but it's negligible in comparison with the MYSQL percentage of use).
> I wonder if to base my functions on the abstract layer of PDO or to use
> mysql function (means "mysql_connect" and so on).
> As I see it, mysql functions are more readable and comfortable, but in this
> case : using MSSQL in the future would affect with new DB module with
> another implementation.
> What do would do in such a situation??

    You could stick with the native mysql_* and mysqli_* functions,
but if you have any hint that your application may eventually change
its database platform, or if you at least want the option to easily
swap, you should definitely use abstraction.  You could use PDO or, as
I did, create your own abstraction layers with a common application
interface.  Then all you need to do is change a configuration variable
if you need to switch from, say, MySQL to SQL Server, PostgreSQL, et
cetera.  The application never notices a difference.  For example:


$db = new DB(DB_PLATFORM);

   There will be some pitfalls and intricacies now and again that
require some additional adjustments in the model, but I've found that,
for myself, I prefer having full control over the code.  Well,
that.... and the fact that it was a specific requirement in the spec
of the project.
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to