PHP and Working with Databases (for the Lazy Sod)

By HTMLGoodies Staff


In this article we have spoken about the benefits of atomic operations, database abstraction and the use of classes.

atomic operations- We have converted the usual gunk of working with databases into a small number of key functions that do no less and no more than needed.

database abstraction- We have created a new set of functions that are entirely database independent (simply by switching one include file). Even better, these new functions require much less code than traditional methods of working with databases (due to our atomic operation implementation).

classes - We have wrapped all of the above up into a nice, easy to use, class/object. This is handy because it allows us to do things like easily manage two concurrent server connections (should we so wish) as well as cache results and offers us neat functions that won't get confused with other global scope functions.

Final Note

If you would like to see more examples of how to work with the class I've written (ezSQL) and how it can make your life easier, just go and have a look at http://php.justinvincent.com.

For a full-blown example of a busy Website built using all the above concepts and the ezSQL class, visit http://vip.channel.ac. It is a collaborative environment where about 2700 users post News, Pictures, Links and FAQs. It also has busy Forums and Live chat. It took about two months to build from scratch (no external scripts or software were used). It gets approximately 95,000 hits to the mySQL database per day (all via ezSQL) and it runs like a charm.

If you would like to help by porting ezSQL to another database platform, please feel free to do so and mail me the code (justin_at_visunet_dot_ie). I will include it in any future distributions. As stated, the only functions you need to change are $db->db, $db->select and $db->query. At the time of writing this article, ezSQL is available for mySQL and Oracle8.

Justin Vincent

Page 6 of 6

Previous Page
1 2 3 4 5 6

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date