Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPBuilder.com:
Object-Relational Mapping in PHP
Mar 09, 2004 @ 13:12:48

PHPBuilder.com has a new piece this morning for anyone out there that's struggled with connecting an RDB (relational database) and PHP. The idea is to create something that, without having to go through tons of changes down the road, can adapt to any changes that may come along.

In A Practical Approach to Object-Relational Mapping in PHP they they show an example of a sample "business class" (that is, a class describing something meaningful to nontechnical people in the business), and how it can cause lots of trouble down the road (with classes upon subclasses and subclasses).

They give a few different options, including: Repeating Code, Extra Queries for New Fields, and, the one they want to focus on, A New Base Class. This base class acts as a qateway for all other classes, not allowing any of them to connect to the database themselves. The business class then works with objects instead of other function calls to move the needed data around. It's quite an interesting way to go about abstracting your databsae connections - too bad it's almost overkill for a simple site...

tagged:

Link:


Trending Topics: