Write the generate Country, State, And City in DatabaseStringConstants.php table name and column name re same
class DatabaseStringConstants {
public static $TBL_COUNTRIES = "countries";
public static $COL_CODE = "code";
public static $COL_NAME = "name";
}
Add Country model in state_country_cities.php
class UtilityService {
static function getBaseDirectory() {
return $_SERVER['DOCUMENT_ROOT'] . "/trulloy_employee_management/";
}
static function getAllCountry() {
$countries = array();
$db = new DBConnectionService();
$con = $db->getConnection();
$selectCountriesSql = "SELECT ".
DatabaseStringConstants::$COL_CODE . ", " .
DatabaseStringConstants::$COL_NAME . " FROM " .
DatabaseStringConstants::$TBL_COUNTRIES .
";";
$result = mysqli_query($con, $selectCountriesSql);
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$country = new Country($row[DatabaseStringConstants::$COL_CODE], $row[DatabaseStringConstants::$COL_NAME]);
array_push($countries, $country);
}
return $countries;
}
}