Home arrow PHP arrow Page 6 - 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 - Conclusion
(Page 6 of 6 )

The advantages of using a database data access object over conventional database access are rather obvious. Of course, there are many cases where the conventional database access may be necessary. For example, in order to retrieve field names and their associated data types from a particular table, we would connect to a database in the conventional way and use the "mysql_fetch_field()" PHP function. The point is that about 95% of the time (if not more) we are simply retrieving data from a database and in that case DAO is the tool of choice.

Although at the beginning of this article I made a claim that the DAO is not an abstraction layer, it is not entirely true. As a matter of fact, I have to admit that our implementation of the DAO can be perceived as a database abstraction layer to a certain degree. The "Core Classes" collection also includes a "MsSqlAdapter," which acts as a DAO for access to Microsoft's SQL Server. Since the exposed class interface is exactly the same as the interface in "MySQL Adapter," scripts that utilize the MySQL DAO can be converted to work with MSSQL server simply by modifying the include statement to include the "mssqladapter.phpclass."

I realize that in addition to retrieving data from a database, many of the scripts need to store data in a database as well. Updating and inserting records in a database is often even more of a hassle than retrieving it, and don't worry, database DAO can do that as well. If you are interested to learn about the remaining functionality of the MySQL data access object, come back and look for the part "deux" of this article.

Support Material

Download the MySQLAdapter DAO Class from http://eof.nlcnet.net/core/MySQLAdapter.zip. The MySQL Adapter is covered under the LGPL license.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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