William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

PEAR: MDB2 2 tips

1. xampp default not install PEAR::MDB2

In Windows 7, apachefriends’s XAMPP defaultly doesn’t install PEAR’s MDB2. I checked the phpinfo(), no PEAR’s MDB2. very simple to install it:

C:\xampp\php>pear install MDB2-2.5.0b3

After installation, the MDB2 is auto extracted in C:\xampp\php\PEAR\ directory (which is available in php.ini’s include_path options). Restart XAMPP, the MDB2 is accessible. Don’t need ini_set(‘include_path’, PEAR_MDB2_PATH) to manually set.

2. Remove Deprecated messages.

if using report error messages in PHP code:

error_reporting(E_ALL);

All error/warnings information will be display on the screen. For the latest MDB2, it keeps warnings like this:

Deprecated: Assigning the return value of new by reference is deprecated …

The reason is that in PHP5 the =& is deprecated.

$mdb2 =& MDB2::factory($dsn, $options);

It is not required and should be removed, like:
$mdb2 = MDB2::factory($dsn, $options);

Except my code, some extra steps need to do to clear all the warnings: because the original MDB2 files are using this way:

  1. C:\xampp\php\PEAR\MDB2.php
  2. C:\xampp\php\PEAR\MDB2\Driver\mysqli.php

Change all the =& to = in this 2 files. This way will remove all the ‘Deprecated’ warning messages from screen.

My PHP version is 5.3.1, and MDB2 version is ‘2.4.1’.

Advertisements

One response to “PEAR: MDB2 2 tips

  1. hotshot bald cop 08/29/2011 at 6:25 pm

    Thank you for a great post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: