Database abstraction? Not for me!

Programming for Search Engines 101. An area for avid PHP and .NET developers to chat about Programming techniques and how to make better use of search engines.

Moderator: Moderators

Database abstraction? Not for me!

Postby Mike » Thu Sep 03, 2009 11:01 am

Several years ago there was a terrific thread on the PHP list regarding database abstraction layers. It broke down into 2 camps, one very enthusiastic about the use of db abstraction, the second dead set against it. For the longest time I used abstraction layers, if only to wrap extension functions inside meaningful functions that worked more intuitively. Not long thereafter I switched camps and essentially stopped using abstraction layers completely.

The posture I have taken follows much along the lines of 2 fairly recognizable people in this industry we are in - Rasmus Lerdorf, author of PHP, and Jeremy Zawodny, next to Monty Widenius one of the most prolific MySQL evangelists to ever live. When these 2 guys start talking about database abstraction layers, it's good to listen. :)



That post was referenced in another that has links to some other discussions



Shedding the abstraction layer dogma was somewhat difficult early on, but with the advent of the new mysqli extension in PHP, things got a little easier, and nicer.

I had a strain of an abstraction layer a friend of mine wrote a few years back that I tweaked for efficiency and ran it, head to head, against a pure mysqli class implementation. The results were quite astonishing. I never really appreciated tyhe cost in terms of overhead my abstraction layer cost me. As a sidenote to the exercise, I ran the same test pitting MySQLi against ADODB. Those results were even more astonishing. I used to have big respect for ADODB, for all the wrong reasons. The test was a real eye opener. ADODB, when compared to pure MySQLi class code, brutalized my application overhead. It was orders of magnitude slower even across the most basic of functionality. Now it could be that in the case of the layer I had writtem, it just wasn't written very well - but who cares. The raw speed difference was enough for me.

Something worth thinking about and talking about, still.

Mike
Mike
 

Re: Database abstraction? Not for me!

Postby douglas » Fri Sep 04, 2009 5:07 am

Me too is the follower of those great fathers Rasmus and Jeremy and like procedural programming and mysql APIs for database connectivity due to its performance aspects and complete control to programmer. I would suggest you should use mysqli PHP extension if you are using PHP 5 and MySQL 4.1+ for database related operations. The mysqli (MySQL improved) extension was developed to take advantage of new features found in MySQL systems versions 4.1.3 and newer. The mysqli extension is included with PHP versions 5 and later. Following are the major features that mysqli offers against MYSQL class.

Object-oriented interface
Support for Prepared Statements
Support for Multiple Statements
Support for Transactions
Enhanced debugging capabilities
Embedded server support

Read more:
douglas
 
Posts: 282
Joined: Fri Feb 20, 2009 3:56 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 11 guests