getMessage()); } $sql = "SELECT `State`, `StateName` "; $sql .= "FROM `States` "; $sql .= "ORDER BY `StateName` "; $result = $db->query($sql); // Always check that $result is not an error if (DB::isError($result)) { die ($result->getMessage()); } $stateArray = array(); while ($row = $result->fetchRow()) { $state = new State(); $state->setState($row[0]); $state->setStateName($row[1]); $stateArray[] = $state; } $result->free(); $db->disconnect(); return $stateArray; } function getState($stateName) { $state = new State(); $db = getConnection(); if (DB::isError($db)) { die($db->getMessage()); } $sql = "SELECT `State`, `StateName` "; $sql .= "FROM `States` "; $sql .= "WHERE `State` = '$stateName' "; $result = $db->query($sql); // Always check that $result is not an error if (DB::isError($result)) { die ($result->getMessage()); } $row = $result->fetchRow(); $state->setState($row[0]); $state->setStateName($row[1]); $result->free(); $db->disconnect(); return $state; } function getCitys($state) { $db = getConnection(); if (DB::isError($db)) { die($db->getMessage()); } $sql = "SELECT `State`, `City`, `Keywords` FROM `Citys` "; $sql .= "WHERE `State` = '$state' "; $sql .= "ORDER BY `City` "; $result = $db->query($sql); // Always check that $result is not an error if (DB::isError($result)) { die ($result->getMessage()); } $cityArray = array(); while ($row = $result->fetchRow()) { $city = new City(); $city->setState($row[0]); $city->setCity($row[1]); $city->setKeywords($row[2]); $cityArray[] = $city; } $result->free(); $db->disconnect(); return $cityArray; } ?>