PHP
  Home arrow PHP arrow Page 6 - Code 10x More Efficiently Using Data Acces...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Code 10x More Efficiently Using Data Access Objects: Part 1
By: Oto Hlincik
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 44
    2003-10-11

    Table of Contents:
  • Code 10x More Efficiently Using Data Access Objects: Part 1
  • The Old Way
  • Code Samples, The Old Way
  • Database DAO to the Rescue
  • Convenience and Performance
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    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.

     

    PHP ARTICLES

    - 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
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway