<?php
// PEAR Benchmark - include the iterate class definition:
/////////////////////////////////////////////////////////////////////////////////////////////
require ('Benchmark/Iterate.php');
// create and start an iteration:
$b = new Benchmark_Iterate();
$b->run(100, 'foo'); // function name
// funtion to be tested
/////////////////////////////////////////////////////////////////////////////////////////////
function foo() {
// database handle using PDO
$dbh = new PDO('mysql:host=localhost;dbname=zip_locations', 'username', 'password');
$state = $_GET['state'];
$stmt = $dbh->prepare("SELECT * FROM zip_codes where state = ?");
$stmt->execute(array($state));
$results = $stmt->fetchAll();
foreach ($results as $key => $value) {
echo $value['zip'] . ' => ' . $state . "\n";
}
$stmt = NULL;
} // end function
/////////////////////////////////////////////////////////////////////////////////////////////
// get the results:
$r = $b->get();
print_r($r);
// delete the object:
unset($b);
/////////////////////////////////////////////////////////////////////////////////////////////
?>