Home arrow PHP arrow Code 10x More Efficiently Using Data Access Objects: Part 1
PHP

Code 10x More Efficiently Using Data Access Objects: Part 1


Learn how to efficiently access database information using Data Access Objects (DAO) with PHP. Oto shows us how easy database manipulation can be, as well as how much time can be saved.

Author Info:
By: Oto Hlincik
Rating: 4 stars4 stars4 stars4 stars4 stars / 51
October 11, 2003
TABLE OF CONTENTS:
  1. · Code 10x More Efficiently Using Data Access Objects: Part 1
  2. · The Old Way
  3. · Code Samples, The Old Way
  4. · Database DAO to the Rescue
  5. · Convenience and Performance
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Code 10x More Efficiently Using Data Access Objects: Part 1
(Page 1 of 6 )

Everyone knows that today an effective website cannot do without dynamic content. Usually this content comes from some kind of database. PHP provides great built-in functions that allow the developer or programmer to access all of the most popular (and many of the not so popular) databases. There is not much work involved in connecting to a database, sending a SQL query over, receiving some kind of data back and then iterating over the returned records and … doing something interesting with it. Sounds pretty straight forward, doesn't it? I guess it does until you need to do the same thing over and over on just about every page, sometimes more than once on a single page, and it becomes even more interesting if you need to access different databases within one script.

One thing that signifies every good programmer is the desire to make coding life easier for him or herself. The first step is to create a reusable chunk of code that can be copied and pasted over and over, with changing parts of it as needed (a technique known as "code reusability). The second step would be creating a function that encapsulates some of this functionality, but ultimately is still not flexible enough to provide the desired reusability.

There must be a better way. And there is! Why not use the Object Oriented Programming capabilities of PHP and encapsulate the functionality that every developer uses about 95% of the time? Let's use a Data Access Object (DAO) for our communication with a database. (For experienced programmers: Don't worry, I am not talking about database abstraction such as PEAR::DB, so read on…)


blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials