class MySQLDB extends mysqli {
public function storedProcedure($proc_name, $params){
$ds = array();
if ($result = $this->query("CALL $proc_name('" . implode("', '", $params) . "');")) {
if ($result->num_rows > 0){
while ($row = $result->fetch_array(MYSQLI_ASSOC)){
$ds[] = $row;
}
$result->close();
}
$this->next_result();
}
$this->commit();
return $ds;
}
}
<?php
$table = "alabama";
$sql = "CALL {$table}_zip();";
$sql .= "CALL {$table}_city();";
$sql .= "CALL {$table}_county();";
$mysqli = new MySQLI('host','user','pass','db');
if ($mysqli->multi_query($sql)) {
do {
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
echo($row[0]);
}
$result->close();
}
if ($mysqli->more_results()) {
echo ("next result");
}
} while ($mysqli->next_result());
}
else {
echo $mysqli->error;
}
$mysqli->close();
?>
$sql = "CALL ".$table."_zip();";
and so on.