PEAR Articles
  Home arrow PEAR Articles arrow Page 2 - A PEAR CMS: Examining the Code
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? 
PEAR ARTICLES

A PEAR CMS: Examining the Code
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-08

    Table of Contents:
  • A PEAR CMS: Examining the Code
  • Connecting to the Database
  • Styles
  • Edit Sections

  • 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


    A PEAR CMS: Examining the Code - Connecting to the Database


    (Page 2 of 4 )


    Next we actually attempt to connect to the database:

    // Creates a database connection object in $db

    // or, a database error object if it went wrong.

    // The boolean specifies this is a persistent

    // connection like mysql_pconnect(), it

    // defaults to FALSE.

    $db = DB::connect($dsn, TRUE);

    As the comments point out, the db::connect() function creates a database connection object in $db, or if there is an error, it creates an error object. The next code block then checks to see if an error occurred during the connection attempt:

    // Check whether the object is a connection or

    // an error.

    // Print out a message and exit if it's

    // an error object.

    if (DB::isError($db)) {

    die($db->getMessage());

    }

    It is always worth checking to see if any errors have occurred; as you will see, I always check for errors when using DB.

    Before we move on to look at the other application-wide scripts, just take a look at the front page of the Content Management System application:


    The two scripts that are responsible for giving this application the neat appearance include the Pear.css script, that has the following styles:

    body {

    font-family: Verdana, Geneva, Arial, helvetica, sans-serif;

    }

    .header{

    font-size:18px;

    font-weight:bold;

    color:#003366;}


    .maintxt{

    font-size:12px;

    }


    .title{

    font-size:12px;}

    .nav{

    font-size:10px;

    font-weight:bold;}

    .auth{

    font-size:10px;

    color:#0000FF;

    font-weight:bold;}


    .copy{

    font-size:8px;

    text-align:right;

    color:#003366;


    }

    /*Admin Styles*/


    .options{


    font-size:14px;

    font-weight:bold;

    color:#0033FF;}

    .bord{

    border:1px solid #FF0000;}

    .header1{

    font-size:18px;

    font-weight:bold;

    color:#003366;

    background-color:#FF6699;}

    .section{

    border:1px solid #333333;

    font-weight:bold;

    color:#003366;

    background-color:#FF6699;}


    .navbord{

    border:1px solid #333333;

    }

    More PEAR Articles Articles
    More By David Web


     

    PEAR ARTICLES ARTICLES

    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT