Home arrow MySQL arrow Page 4 - Working with PHP and MySQL

Using PEAR - MySQL

Last week, you began learning how to use PHP to display and modify data from a MySQL database. This week, you'll learn how to select the database, fetch and display data, and more. This article is excerpted from chapter 9 of Learning PHP and MySQL, written by Michele Davis and Jon Phillips (O'Reilly, 2006; ISBN: 0596101104). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Working with PHP and MySQL
  2. Fetching and Displaying
  3. Putting It All Together
  4. Using PEAR
By: O'Reilly Media
Rating: starstarstarstarstar / 15
May 24, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

PEAR is a framework and distribution system for reusable PHP components. Actually, PEAR is a collection of add-on functionality for PHP development. There are many modules available to handle everything from session management to shopping cart functionality. Modules that are currently available are listed in Table 9-1.

Table 9-1.  Pear modules

Authentication

HTML

Processing

Benchmarking

HTTP

Science

Caching

Images

Semantic Web

Configuration

Internationalization

Streams

Console

Logging

Structures

Database

Mail

System

Date/Time

Math

Test

Encryption

Networking

Tools & Utilities

Event

Numbers

Validate

File Formats

Payment

Web Services

File System

PEAR

XML

GTK Components

PHP

 

Our list is not complete. Visit http://pear.php.net to find out all of the modules that are available for download.

Installing

PEAR uses a Package Manager to manage which PEAR features you install. Whether you need to install the Package Manager depends on which version of PHP you installed. If you're running PHP 4.3.0 or newer, it's already installed. If you're running PHP 5.0, PEAR has been split out into a separate package. The DB package that you're interested in is also installed by default with the Package Manager. So if you have the Package Manger, you're all set.

Unix

You can install the Package Manager on a Unix system by executing the following from the shell (command-line) prompt:

  lynx -source http://go-pear.org/ | php

This takes the output of the go-pear.org site (which is actually the source PHP code) to install PEAR and passes it along to the php command for execution.

Windows

The PHP 5 installation includes the PEAR installation script as C:\php\go-pear.bat. In case you didn't install all the files in Chapter 2, go ahead and extract all the PHP files to C:/php from the command prompt, and execute the .bat file. Figure 9-5 shows the initial screen after executing the PEAR installer. 


Figure 9-5.  The go-pear.bat install script

You'll be asked a set of questions about paths. You can accept the defaults for all of them.

The php.exe file must be in your path. Verify by typing php.exe from a command prompt. If it is not found, you'll need to add it to your PATH variable. To access your system path, navigate to Start -> Control Panel -> System -> Environment and add an entry to the end of the path with C:\php.

The PEAR installer creates a file called C:\php\PEAR_ENV.reg. You need to double-click to set up the PEAR paths in the registry. This file is contingent on which PEAR version you installed. When the dialog box appears to verify your information, you will add this to the registry and click OK.

You may have to edit the php.ini file after running this .bat file to add the PEAR directory to the include path. Line 447 of php.ini now looks like this:

  include_path = ".;c:\php\includes;c:\php\PEAR"

Apache must be restarted before the DB package can be used.

Please check back next week for the conclusion to this article.


 
 
>>> More MySQL Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...
- Building a PHP ORM: Deploying a Blog
- TROSYS Launches Free MySQL Manager and Admin...
- Building an ORM in PHP: Domain Modeling
- Building an ORM in PHP
- MySQL Leads Open Source Market, Gets Cluster...
- Oracle Announces Milestone Release for MySQL
- How to Stop SQL Injection Attacks
- New Defragmentation Solution for SQL Server
- Comparison of MyISAM and InnoDB MySQL Databa...


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

Dev Shed Tutorial Topics: