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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.