Page 1 of 1

using PDO vs mysql extension

Posted: Wed Jan 05, 2011 2:01 am
by mirian
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 abstrat 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??
Thanks,
Miriam

Re: using PDO vs mysql extension

Posted: Wed Jan 05, 2011 2:46 am
by greyhoundcode
You might also consider something like Doctrine in this situation. PDO or not, your going to have to make some changes/additions to your SQL code if you use different RDBMSs.

Re: using PDO vs mysql extension

Posted: Mon Jan 10, 2011 12:15 pm
by Brian Swan
I think you want to use some type of abstraction layer. PDO would be a good start, but as greyhoundcode points out, you will still have to modify your SQL strings for different RDMSs. I don't know if Doctrine does SQL query translation, but if it does, it's probably worth investigating...might save you lots in maintenance down the road.

Just my $0.02.

-Brian

Re: using PDO vs mysql extension

Posted: Mon Jan 10, 2011 12:29 pm
by greyhoundcode
Yeah I don't think it translates one form of SQL into another, as such, but it does have something called Doctrine Query Language that lets you write queries against object models (rather than database tables themselves).