/**
* 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)
{
$model=Personaddress::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
Ejemplo n.º 2
0
 public function saveOrUpdatePersonAddress($model, $addrtype = null)
 {
     $rtn = true;
     $paramarray = array(
                             'person_id'=> $model->id,
                             'location_id'=> $model->address->id,                                
                         );
     if(!empty($addrtype))
     {
         $paramarray['type'] = $addrtype;
     }
     $records = Personaddress::model()->findAllByAttributes($paramarray);
     $found = count($records) > 0;
     if($found)
     {
         $record = $records[0];
     }
     else
     {
         $record = new Personaddress;
     }
     $record->type = $model->addresstype;
     $record->person_id = $model->id;
     $record->location_id = $model->address->id;
     $rtn = $record->save();
     $model->address = $record;
     return $rtn;
 }
Ejemplo n.º 3
0
 private function deletePersonAddrData($id, $addr_type){
     if(!is_array($addr_type)) $addr_type = array($addr_type);
     $result = \Personaddress::find('all', array('conditions' => array('person_id=? AND type IN (?)', $id, $addr_type)));
     foreach($result as $data){
         $data->delete();
     }
 }