Database Articles
  Home arrow Database Articles arrow Page 4 - Intro to Databases
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
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? 
DATABASE ARTICLES

Intro to Databases
By: lig
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2005-10-18

    Table of Contents:
  • Intro to Databases
  • Database Basics
  • SQL - Structured Query Language
  • Working with Databases
  • Connecting to the database and selecting the database
  • Sending a Query to the Database and Getting the Results
  • Freeing the Results and Closing Down
  • 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
     
     
    ADVERTISEMENT


    Intro to Databases - Working with Databases


    (Page 4 of 8 )

    There are many ways a user can work with a database. The user may use the native functions available through php for the particular database, the PEAR DB package, the ADOdb package, or the user can create a custom database package. Each of these options have good and bad points but we will be discussing and comparing the native functions for a database and the PEAR DB ackage.

    In my examples I will pretend to be using a MySQL database. You can find the native functions for it here in the manual. If you are using a different database system simply go to the user manual and look for your system - there you will find it's listing of available functions. If you still can't find your database system - look at the list of systems supported by the ODBC drivers. I will not be using all of the available functions for MySQL.

    You can find the documentation for the PEAR DB here to look up what I am discussing or for your future reference.

    In this section of the article we will compare/demonstrate native database functions vs. PEAR DB. First we will quickly go over some of the advantages/disadvantages of the 2, then how to connect to the database with each, how to send a query and retreive the results, and lastly how to free the results and close the connection.

    Please notice that I will be including code to handle possible errors that may occur. You should NEVER assume that what should happen always will. All the error code will be commented so you follow what it is doing. Murphy (aka Murphy's Law) tends to pop up when ever and where ever he chooses, so make sure you are ready for him.

    Advantages

    The biggest advantage of native functions is speed. Nothing else compares. The next major advantage is simply that the functions available for a database - maximize the database's effectiveness. Native functions for a database system takes advantage of all the systems capabilities.

    The biggest advantage of PEAR DB is its portability. This package can work with MySQL, PostgreSQL, MSSQL, and a host of others. The only thing that will have to be changed is 1 to 2 lines to switch between database systems. The next major advantage is that it is Object Oriented. With the the new Object Oriented PHP 5 this is a definate advantage.

    Disadvantages

    Native functions are database specific. If you change from a MySQL database to a PostgreSQL database - all your function names will have to be changed. And some function calls that were available in one database system may not be available in another. Also if you are programming with objects - depending on how you program it - you may have to create a wrapper class for the database.

    PEAR DB is slow. Granted there are ways to speed it up but it still will not be as fast as the native functions. Also PEAR DB has a limited number of method calls - so you may have to make 3 rights to go left. Lastly - PEAR DB may not be automatically installed in your server. So you may have to install a local version if you are on a shared server (there are instructions for what to do in the PEAR manual).

    More Database Articles Articles
    More By lig


     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek