protected function createCountryField() { $dao = new CountryDAO(); $recordList = $dao->getSimpleList(); $options = array(0 => '<choose>') + $dao->modifyListForSelect($recordList, '<countryName>'); $this->form->addField(new CoreFormFieldSelect('countryId', null, $options)); }
public static function getInstance() { if (!self::$instance) { self::$instance = new CountryDAO(); } return self::$instance; }
/** * Override default validation * @see Phreezable::Validate() */ public function Validate() { // example of custom validation // $this->ResetValidationErrors(); // $errors = $this->GetValidationErrors(); // if ($error == true) $this->AddValidationError('FieldName', 'Error Information'); // return !$this->HasValidationErrors(); return parent::Validate(); }
<?php $postdata = file_get_contents("php://input"); $request = json_decode($postdata); //Get table to be accessed in DB and possible parent related @($option = $request->option); @($parentId = $request->parentId); switch ($option) { //Country case case "Country": //Load Country VO and DAO files include '/VO/CountryVO.php'; include '/DAO/CountryDAO.php'; $countryDAO = new CountryDAO(); //Get all countries $optionVO = $countryDAO->getCountries(); //getData break; //State case //State case case "State": //Load State VO and DAO files include '/VO/StateVO.php'; include '/DAO/StateDAO.php'; $stateDAO = new stateDAO(); //Get all states of a country $optionVO = $stateDAO->getAllByCountry($parentId); //getData break; //City case //City case
protected function getCountryByPrefix($number) { $countryDAO = new CountryDAO(); return $countryDAO->getRecordByAbbr(substr(trim($number), 0, 2)); }
<?php //Include DAO and VO for author include '/VO/CountryVO.php'; include '/DAO/CountryDAO.php'; $postdata = file_get_contents("php://input"); $request = json_decode($postdata); @($tag = $request->tag); $countryDAO = new CountryDAO(); switch ($tag) { case "insert": //Create a country with all info from http @($name = $request->name); $countryVO = new CountryVO('', $name); return $countryDAO->save($countryVO); break; case "select": //Get all countries $countryVO = $countryDAO->getCountries(); break; case "update": //Delete a country @($id = $request->id); $countryVO = $countryDAO->getById_country($id_country); return $countryDAO->delete($countryVO); break; } $country = ""; //Send all countries separated by ';' for ($i = 0; $i < count($countryVO); $i++) { $country = $country . $countryVO[$i]->toString() . ';';