model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : SiteSubspecialtyAnaestheticAgent
return SiteSubspecialtyAnaestheticAgent the static model class
 public function actionAdd()
 {
     $subspecialtyId = $this->request->getParam('subspecialty_id');
     $siteId = $this->request->getParam('site_id');
     $anaestheticAgentId = $this->request->getParam('anaesthetic_agent_id');
     if (!Yii::app()->request->isAjaxRequest) {
         $this->render('errorpage', array('errormessage' => 'notajaxcall'));
     } else {
         if (!is_numeric($subspecialtyId) || !is_numeric($siteId) || !is_numeric($anaestheticAgentId)) {
             echo 'error';
         } else {
             $criteria = new CDbCriteria();
             $criteria->condition = 'anaesthetic_agent_id=:anaesthetic_agent_id AND site_id=:site_id AND subspecialty_id=:subspecialty_id';
             $criteria->params = array(':anaesthetic_agent_id' => $anaestheticAgentId, ':site_id' => $siteId, ':subspecialty_id' => $subspecialtyId);
             $currentSSAA = SiteSubspecialtyAnaestheticAgent::model()->findall($criteria);
             if (!$currentSSAA) {
                 $newSSAA = new SiteSubspecialtyAnaestheticAgent();
                 $newSSAA->subspecialty_id = $subspecialtyId;
                 $newSSAA->site_id = $siteId;
                 $newSSAA->anaesthetic_agent_id = $anaestheticAgentId;
                 if ($newSSAA->save()) {
                     echo 'success added to SSAA';
                 } else {
                     echo 'error';
                 }
             } else {
                 echo 'success';
             }
         }
     }
 }
 public function actionAdd()
 {
     $subspecialtyId = $this->request->getParam("subspecialty_id");
     $siteId = $this->request->getParam("site_id");
     $anaestheticAgentId = $this->request->getParam("anaesthetic_agent_id");
     if (!Yii::app()->request->isAjaxRequest) {
         $this->render("errorpage", array("errormessage" => "notajaxcall"));
     } else {
         if (!is_numeric($subspecialtyId) || !is_numeric($siteId) || !is_numeric($anaestheticAgentId)) {
             echo "error";
         } else {
             $newSSAAD = new SiteSubspecialtyAnaestheticAgentDefault();
             $newSSAAD->subspecialty_id = $subspecialtyId;
             $newSSAAD->site_id = $siteId;
             $newSSAAD->anaesthetic_agent_id = $anaestheticAgentId;
             if ($newSSAAD->save()) {
                 // If an agent is selected that is not in the site_subspecialy_anaesthetic_agent table,
                 // then the selected agent should automatically be added to that table as well
                 $criteria = new CDbCriteria();
                 $criteria->condition = 'anaesthetic_agent_id=:anaesthetic_agent_id AND site_id=:site_id AND subspecialty_id=:subspecialty_id';
                 $criteria->params = array(':anaesthetic_agent_id' => $anaestheticAgentId, ':site_id' => $siteId, ':subspecialty_id' => $subspecialtyId);
                 $currentSSAA = SiteSubspecialtyAnaestheticAgent::model()->findall($criteria);
                 if (!$currentSSAA) {
                     $newSSAA = new SiteSubspecialtyAnaestheticAgent();
                     $newSSAA->subspecialty_id = $subspecialtyId;
                     $newSSAA->site_id = $siteId;
                     $newSSAA->anaesthetic_agent_id = $anaestheticAgentId;
                     if ($newSSAA->save()) {
                         echo "success added to SSAA";
                     } else {
                         echo "error";
                     }
                 } else {
                     echo "success";
                 }
             } else {
                 echo "error";
             }
         }
     }
 }