dbo Posted March 7, 2008 Share Posted March 7, 2008 Looking for some views on the best approach for coming up with a database abstraction layer. Obviously I want a standard interface to work with, but the main concern is being able to keep from marrying my application to any particular database. I've been researching a bit and see the following options. Custom - lightweight, takes some time to build, must research the individual interfaces to make sure the interface will truly be standard (accept appropriate number of parameters, etc) PDO - lightweight, requires additional extensions be installed on your server... my current host only allows for sqlite Pear::DB - bulky and slower, requires Pear... other than being inefficient due to bloat seems to be robust ADO - don't know much about this one I dunno, each solution seems to have its positives and negatives. Struggling with which route I should go. Some of the concerns I'm struggling with are as follows: -True standard interface -Ease of implementation -Minimal additional requirements -Efficiency -Works today and tomorrow... not experimental Anyways, as usual it's just some random firings that are going in my head. I'm looking for some advice and suggestions from your own personal experiences. Thanks! Quote Link to comment Share on other sites More sharing options...
koen Posted March 9, 2008 Share Posted March 9, 2008 Another option is the one used by CakePHP. I only very briefly looked at it but it doesn't seem to require anything other than the files itself. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 I think I've decided to use Pear, despite the performance hit I take. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 I take that back, Pear::DB apparently has a younger... more slim brother MDB2. I must say, I'm more partial to using Pear modules since PHP6 is supposedly going to be relying on it more heavily (presumably to increase the popularity of Pear). I've heard native mysql functions will be inside of Pear in PHP6, rather than in the core... I dunno though. I've not followed it extensively. Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 I've heard native mysql functions will be inside of Pear in PHP6, rather than in the core... I dunno though. I've not followed it extensively. I would assume that meens PECL as mysql* is an extension written in C, not native php. I really think you ought to reconsider PDO. It (and the sqlite driver) ships with php5 by default (though you still need to make sure the required drivers (ie mysql/postgres etc etc) are installed) and is an extension written in C (not a native php lib), this usually makes things much quicker. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 I'm not against using PDO, we'll see if my host will enable other drivers though. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 I've heard native mysql functions will be inside of Pear in PHP6, rather than in the core... I dunno though. I've not followed it extensively. I would assume that meens PECL as mysql* is an extension written in C, not native php. I really think you ought to reconsider PDO. It (and the sqlite driver) ships with php5 by default (though you still need to make sure the required drivers (ie mysql/postgres etc etc) are installed) and is an extension written in C (not a native php lib), this usually makes things much quicker. Even more proof of how little I've followed it I'm talking to my host right now. They're basically saying that they can't enable other extensions for PDO. I'll push a little harder to see if they can accommodate me, but I don't have very high expectations. Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 if your host won't enable any other drivers for PDO Id'e suggest finding a better host. as far as I'm aware, PDO is the future of database interaction with php. From what a gather (here) if anything, all database API's will be moved into PECL except PDO which looks like will be pushed as the default database access method. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 Well I just talked to a little tech weenie who can't do anything. I've got an email into an admin to find out for sure. Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted March 9, 2008 Share Posted March 9, 2008 I take that back, Pear::DB apparently has a younger... more slim brother MDB2. I must say, I'm more partial to using Pear modules since PHP6 is supposedly going to be relying on it more heavily (presumably to increase the popularity of Pear). I've heard native mysql functions will be inside of Pear in PHP6, rather than in the core... I dunno though. I've not followed it extensively. I really hope this is not true as that would make things slower(I mean the current mysql functions and other database function are written in C rather than something like pear with is PHP). I mean if they really want to push PEAR, build PEAR's functionality into the core of PHP not the other way around. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 Read thorpe's reply. I was wrong... I think he clears it up. Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted March 9, 2008 Share Posted March 9, 2008 let me see if i understand correctly, allof the mysql_*, mssql_*, etcc are going to be removed and put into the PECL, wont that brake alot of php5 => php6 code? Quote Link to comment Share on other sites More sharing options...
dbo Posted March 9, 2008 Author Share Posted March 9, 2008 Sound's about right. Quote Link to comment Share on other sites More sharing options...
trq Posted March 10, 2008 Share Posted March 10, 2008 let me see if i understand correctly, allof the mysql_*, mssql_*, etcc are going to be removed and put into the PECL, wont that brake alot of php5 => php6 code? The link I pointed to indicated that this was thought of, but for the time being decided against. That's how I read it anyway. And no it wouldn't break any code, it would just mean that the required extensions would need to be installed via PECL. As it is now, the mysql extension is not built into php by default. All that moving it into PECL would mean is that there is an easier install method available. Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted March 10, 2008 Share Posted March 10, 2008 i guess i should convert my database class in my framework to PDO to make things easier and perpared for PHP6 just incase. Quote Link to comment Share on other sites More sharing options...
koen Posted March 10, 2008 Share Posted March 10, 2008 Is there any indication that if they push PDO to be the standard the mysqli drivers for it will be enabled by default? Quote Link to comment Share on other sites More sharing options...
trq Posted March 10, 2008 Share Posted March 10, 2008 Is there any indication that if they push PDO to be the standard the mysqli drivers for it will be enabled by default? Not that I've heard anywhere. Can't see why they would, both the mysql and mysqli extensions need to be explicitly enabled by default as it is now. This behavour was not that long ago changed. Quote Link to comment Share on other sites More sharing options...
koen Posted March 11, 2008 Share Posted March 11, 2008 I think we'll get scenario's as described above. Hosts who have enabled the mysql/mysqli extension and aren't going to enable extra extensions for working with pdo. Quote Link to comment Share on other sites More sharing options...
dbo Posted March 11, 2008 Author Share Posted March 11, 2008 UPDATE: I was able to get my host to enable the mysql extension... since they like me. I guess that means I'll go the PDO approach. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.