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
using PDO vs mysql extension
Moderator: General Moderators
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: using PDO vs mysql extension
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.
-
Brian Swan
- Forum Newbie
- Posts: 17
- Joined: Thu Jan 14, 2010 11:56 am
Re: using PDO vs mysql extension
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
Just my $0.02.
-Brian
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: using PDO vs mysql extension
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).