SiteSubspecialtyAnaestheticAgent::model PHP Method

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 static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

Usage Example

 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';
             }
         }
     }
 }
All Usage Examples Of SiteSubspecialtyAnaestheticAgent::model
SiteSubspecialtyAnaestheticAgent