Zend
  Home arrow Zend arrow Page 2 - 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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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


    Build Database Interfaces - Replacement Example


    (Page 2 of 4 )


    Here is an example in which a database interface has replaced an embedded DML operation:

    <?php 
    /* Update the client's contact information with the data from $_POST */ 
    $userID     = (int) $_POST['userID'];
    $email      
    trim(addslashes($_POST['email']));
    $firstname  
    trim(addslashes($_POST['firstname'])); 
    $lastname   
    trim(addslashes($_POST['lastname'])); 
    $address1   
    trim(addslashes($_POST['address1'])); 
    $address2   
    trim(addslashes($_POST['address2'])); 
    $city       
    trim(addslashes($_POST['city'])); 
    $province   
    trim(addslashes($_POST['province'])); 
    $country    
    trim(addslashes($_POST['country' ])); 
    $DML 'UPDATE clients SET '
           
    "email     = '$email',"
           
    "firstname = '$firstname',"
           
    "lastname  = '$lastname',"
           
    "address1  = '$address1',"
           
    "address2  = '$address2',"
           
    "city      = '$city',"
           
    "province  = '$province',"
           
    "country   = '$country',"
           
    "WHERE userID=$userID"
    if 
    ($db->Execute($DML)) 

        
    // do error handling 

    ? > 
    <?php 
    $client 
    = new Client(); 
    $client
    ->setUserID    $_POST['userID'   ); 
    $client
    ->setEmail     $_POST['email'    ); 
    $client
    ->setFirstname $_POST['firstname'); 
    $client
    ->setLastname  $_POST['lastname' ); 
    $client
    ->setAddress1  $_POST['address1' ); 
    $client
    ->setAddress2  $_POST['address2' ); 
    $client
    ->setCity      $_POST['city'     ); 
    $client
    ->setProvince  $_POST['province' ); 
    $client
    ->setCountry   $_POST['country'  ); 
    if (
    $client->submit($db) !== true

        
    // do error handling 

    ? > 


    The example above demonstrates a reduction in Application Logic. The DB interface handles all communications with the database, and the programmer can focus on the success or failure of the operation. Using less code to do the same task is most beneficial when there are many parts of the application performing the same DML operations. Rather than duplicating DML queries, you simply use the necessary database interface.

    More Zend Articles
    More By Zend


     

       

    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

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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