Hi, I am attempting to follow this tutorial :
http://www.phpro.org/tutorials/Geo-Targetting-With-PHP-And-MySQL.html#1
Using the code :
<?php
/*
*
* @get spacial proximity based on zip/post code
*
* @param int $zip
*
* @param int $distance
*
* @param int $precision
*
* @param int $unit, default 'K'
*
* @return array
*
*/
function getSpatialProximityByZip($zip, $distance, $precision, $unit='K')
{
/*** the sql ***/
$sql = "CALL zip_radius(:unit, :zip, :distance, :precision)";
try
{
/*** an instance of PDO singleton ***/
$stmt = db::getInstance()->prepare($sql);
/*** bind the paramaters ***/
$stmt->bindParam(':zip', $zip, PDO::PARAM_INT);
$stmt->bindParam(':unit', $unit, PDO::PARAM_STR);
$stmt->bindParam('distance', $distance, PDO::PARAM_INT);
$stmt->bindParam(':precision', $precision, PDO::PARAM_INT);
/*** execute the query ***/
$stmt->execute();
/*** return the distance ***/
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch( Exception $e )
{
echo $e->getMessage();
return false;
}
}
?>
<?php
/*** call funciton with zip code ***/
$cities = getSpatialProximityByZip(28034, 10, 2, 'M');
/*** loop over the result set ***/
foreach( $cities as $city )
{
/*** print the arrays ***/
print_r($city);
}
?>
I am getting an error :
Fatal error: Class 'db' not found
I can't see anything that I missed.. if anyone has some insight, would be most appreciated!