Database Articles

  Home arrow Database Articles arrow Page 5 - Database Abstraction with PEAR
DATABASE ARTICLES

Database Abstraction with PEAR
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-07-28

    Table of Contents:
  • Database Abstraction with PEAR
  • What is PEAR?
  • DB::connect
  • DB::disconnect
  • DB::isError
  • DB::getOne and DB::query()
  • DB_Result::fetchRow

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Database Abstraction with PEAR - DB::isError


    (Page 5 of 7 )

    boolean isError (DB_Error $value)

    The error support built into the database abstraction class in PEAR is second to none. When using one of the many database functions, if there is an error an error object will be returned. You can check if the object returned is an error with DB::isError. We can check if a connection attempt returns an error or if a query returns an error. If the object is an error, the function returns true. Otherwise, it returns false. If we determine that we are dealing with an error object, then there are methods of that error object we can use to display the error.

    It is always good practice to check for return errors when making connections or querying a database. Here is an example use of DB::isError for testing if a connection was made:

    <?php
    $db 
    DB::connect($dsn);
    if (
    DB::isError($db)) {
        die (
    $db-&gt;getMessage());
    }
    ?>

    More Database Articles Articles
    More By Matt Wade

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap