PEAR: MDB2 2 tips
Blogs20112011-06-09
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:xamppphp>pear install MDB2-2.5.0b3After installation, the MDB2 is auto extracted in C:xamppphpPEAR 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:
- C:xamppphpPEARMDB2.php
- C:xamppphpPEARMDB2Drivermysqli.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ā.
