Ejemplo n.º 1
0
 $arrayType = array('H' => array('id' => 18, 'title' => 'HDB Apartment'), 'K' => array('id' => 0, 'title' => 'Block'), 'A' => array('id' => 1, 'title' => 'Apartment/Condo'), 'C' => array('id' => 3, 'title' => 'Condominium'), 'S' => array('id' => 0, 'title' => 'Standard'), 'G' => array('id' => 0, 'title' => 'Godown'), 'P' => array('id' => 0, 'title' => 'PO Box, My Mail Box or My SingPost'), 'B' => array('id' => 0, 'title' => 'Locked Bag'), 'W' => array('id' => 0, 'title' => 'Window Delivery'), 'U' => array('id' => 5, 'title' => 'Walk-up'));
 $criteria = new CDbCriteria();
 foreach ($data as $v) {
     $criteria->compare('t.postal_code', trim($v), true, 'OR');
 }
 $dataTmp = ApiPostcode::model()->findAll($criteria);
 if ($dataTmp) {
     $tmp = array();
     $building = array();
     $buildingTmp = array();
     //search postal code
     foreach ($dataTmp as $v) {
         $code = substr($v->postal_code, 0, 6);
         $type = substr($v->postal_code, 6, 1);
         $keyBuilding = substr($v->postal_code, strlen($v->postal_code) - 6, strlen($v->postal_code));
         $building[$code] = $keyBuilding;
Ejemplo n.º 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     try {
         $model = FiInvoice::model()->findByPk($id);
         if ($model === null) {
             Yii::log("The requested page does not exist.");
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         return $model;
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }