falltime Posted July 31, 2008 Share Posted July 31, 2008 It is sort of a strange question, but I'm wondering what a few gurus might consider would be the best (efficiency-wise) way to write a DB abstraction class for MySQLI. I have a number of DB abstraction classes that I've written in the past that are loaded dynamically by a class factory. Although I've generally just used MySQL, its comforting to know I could switch to most other DB's without much of a problem. My original MySQL abstraction was pretty basic - abstracted common methods were used to call MySQL procedural functions. Nothing real fancy simply because there is only one real obvious approach. With MySQLI however, I'm a bit perplexed mainly because of the different approaches one can take when creating DB class: 1. I could create a class that simply calls the MySQLI procedural functions and stores the link identifier within the class - essentially the exact same way I created the MySQL class. 2. I could extend the MySQLI class and translate the methods so that the abstracted common methods basically recall the corresponding parent MySQLI class methods. 3. I could write a class that calls the OO methods instead of the procedural methods (similar to option 2 but no extension); For some reason options 2 and 3 just seem a bit off to me - I'm under the slight impression that the MySQLI class itself is in fact just doing what I would do in Option 1 and it feels like I'd be going through 2 layers. Quote Link to comment Share on other sites More sharing options...
dbo Posted August 1, 2008 Share Posted August 1, 2008 It's not meant as a full database abstraction layer, but I would look at PDO. 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.