Install PEAR DB module under XAMPP
A PHP version of Google Map API requires PEAR::DB module to cache map data from Google servers. PEAR is an extension for PHP, and you need to install it yourself. I use XAMPPLite as my dev environment, below are the steps how to install this module.Step 1 - Setting up environment variables
Go to My Computer-> System Properties -> Advanced -> Environment Variables -> System variables -> Path. The path looks like this: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem. Append the XAMPP PHP directory at the back of what is already there: ;C\xampplite\php\Step 2 - Install PEAR extension
Open a command line window (cmd), run the batch file go-pear.bat under the PHP folder and follow the instructions. The PEAR extension get installed in C:\xampplite\php\PEAR directory for my case.Step 3 - Add DB module
Once PEAR is installed, go to the php.ini file in your Apache folder. Find the line ;include_path = ".;c:\\xampplite\\php\\includes", remove the begining semi-colon to un-comment it and then add C:\xampplite\php\PEAR to it. In the command line window, execute the following: pear install DB.Step 4 - Test PEAR
Assume you have a database created using phpMyAdmin, in your htdocs folder create a file called
testDB.php
<?php
require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'password';
$db_name = 'dataBase_name';
$dsn = "mysql://$db_user:$db_pass@unix+$db_host/$db_name";$db = DB::connect($dsn);
$db->setFetchMode(DB_FETCHMODE_OBJECT);
?>
This will use the PEAR DB to create a connection to the database, if no errors are listed, then you are good to go。
如果下载的是最新xampp,那么pear中的包已经包含了MDB2了,只是没有DB