model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : the
return the static model class
示例#1
0
 /**
  * Update the enabled status of the given reason.
  */
 public function actionSetNoTreatmentReasonStatus()
 {
     if ($model = models\OphCiExamination_InjectionManagementComplex_NoTreatmentReason::model()->findByPk((int) @$_POST['id'])) {
         if (!array_key_exists('enabled', $_POST)) {
             throw new \Exception('cannot determine status for reason');
         }
         if ($_POST['enabled']) {
             $model->active = true;
         } else {
             $model->active = false;
         }
         if (!$model->save()) {
             throw new \Exception('Unable to set reason status: ' . print_r($model->getErrors(), true));
         }
         Audit::add('admin', 'set-reason-status', @$_POST['id'], null, array('module' => 'OphCiExamination', 'model' => 'OphCiExamination_InjectionManagementComplex_NoTreatmentReason'));
     } else {
         throw new \Exception('Cannot find reason with id' . @$_POST['id']);
     }
 }
 /**
  * get the list of no treatment reasons that should be used for this element
  *
  * @return OphCiExamination_InjectionManagementComplex_NoTreatmentReason[]
  */
 public function getNoTreatmentReasons()
 {
     return OphCiExamination_InjectionManagementComplex_NoTreatmentReason::model()->activeOrPk(array($this->left_no_treatment_reason_id, $this->right_no_treatment_reason_id))->findAll();
 }