• Blogs (9)
    • šŸ“± 236 - 992 - 3846

      šŸ“§ jxjwilliam@gmail.com

    • Version: ā€šŸš€ 1.1.0
  • 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.0b3

    After 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:

    1. C:xamppphpPEARMDB2.php
    2. 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’.