Zend
  Home arrow Zend arrow Page 4 - Build Database Interfaces
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
VPS Hosting 
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? 
ZEND

Build Database Interfaces
By: Zend
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2004-01-04

    Table of Contents:
  • Build Database Interfaces
  • Replacement Example
  • Lessen the Impact
  • Autonomous

  • 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
     
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Build Database Interfaces - Autonomous


    (Page 4 of 4 )


    Design the DB interface for a single purpose. This purpose is usually creating, updating and deleting a row of data. DB interfaces should be as autonomous as possible because that makes it easier to use them as a group. It is easier to combine the operations of multiple interfaces when each interface has a well-defined set of operations. (See example below.)

    Standardized Design
    Large applications that have many database tables result in many DB interfaces. Standardizing the way database interfaces are built makes them a lot easier to work with and become familiar with. Use a standard naming scheme, layout and implementation to simplify using multiple interfaces together.

    Putting the Pieces Together
    A single DB Interface is fairly limited in its usefulness. DB interfaces become very useful when their functionality is grouped together to perform a real task. Here is an example in which multiple database interfaces are combined to complete a new message posting on a forum:


    <?php 
    /* Notes: 
       $db    - instance of ADOdb connection object. 
       $user  - instance of the User DB Interface 
       $topic - instance of the Topic DB Interface 
    */ 

    $db
    ->StartTrans(); 

    // update the user's total # of posts 
    $user->setNumPosts($user->getNumPosts() + 1); 
    $user->submit($db); 
    // update the topics # of messages 
    $topic->setNumMessages($topic->getNumMessage() + 1); 
    $topic->submit($db); 
    // create the new message 
    $message = new Message(); 
    $message->setTopicID($topic->getTopicID()); 
    $message->setTopic($_POST['userTopic']); 
    $message->setMessage($_POST['message']); 
    $message->setPoster($user->getUserID()); 
    $message->submit($db); 
    $db->CompleteTrans(); 
    ? > 

    Conclusion
    This article provided an introduction to using the DB interface design model for creating applications. As PHP applications become increasingly complex, they inevitably become more difficult to manage. Database interfaces provide a mechanism and a methodology for building more manageable applications faster and easier.


      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.

       

         

      ZEND ARTICLES

      - Taking the Zend Certified PHP Engineer Exam:...
      - Quick Introduction to PHP 5
      - PHP SOAP Extension
      - Improving Performance
      - PDFs with PHP part 2
      - PDFs with PHP part 1
      - PHP at Lycos
      - Build Database Interfaces





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