Jump to content

MySQLI DB Abstraction


falltime

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/117483-mysqli-db-abstraction/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.