In MVC, the controller usually takes care of user interaction, so the user does not have direct access to the model, but does so through the controller. The controller intercepts user actions and does the work, invoking the model (s). Therefore, it is better not to name the model function directly, even if it is possible.
, , , () controller, , , .
() , URL-, , , onclick. , , URL-, URL- ajax.
: 1) :
public function actionMyaction($id){
$sampleMod=SampleModel::model()->findByPk($id);
$sampleMod->deleteImage();
Yii::app()->end();
}
2) : <input type="button" value="delete image"/> CHtml helper class ajaxButton.
echo CHtml::ajaxButton('Delete Image',Yii::app()->createUrl('controllername/actionname',array('id'=>$id)));
$id.