model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : CommonSystemicDisorder
return CommonSystemicDisorder the static model class
 public function actionDelete($itemId)
 {
     /*
      * We make sure to not allow deleting directly with the URL, user must come from the commondrugs list page
      */
     if (!Yii::app()->request->isAjaxRequest) {
         $this->render('errorpage', array('errorMessage' => 'notajaxcall'));
     } else {
         if ($commonMedications = CommonMedications::model()->findByPk($itemId)) {
             $commonMedications->delete();
             echo 'success';
         } else {
             $this->render('errorpage', array('errormessage' => 'recordmissing'));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param $subspecialty_id
  *
  * @return array
  */
 public function listBySubspecialtyWithCommonMedications($subspecialty_id)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('subspecialty_id', $subspecialty_id);
     $drugs = self::model()->with('subspecialtyAssignments')->findAll($criteria);
     $common_medication_drugs = CommonMedications::model()->with('medication_drug')->findAll();
     $return = array();
     foreach ($drugs as $drug) {
         $return[] = array('label' => $drug->name, 'value' => $drug->name, 'id' => $drug->id);
     }
     foreach ($common_medication_drugs as $common_medication_drug) {
         $return[] = array('label' => $common_medication_drug->medication_drug->name, 'value' => $common_medication_drug->medication_drug->name, 'id' => $common_medication_drug->medication_drug->id . '@@M');
     }
     asort($return);
     return CHtml::listData($return, 'id', 'label');
 }