Exemplo n.º 1
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;
 }
/**
* 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;
}