change default sql string

Good evening, I’m a Italian boy and forgive my English.

I hope you help me solve my problem.

How do I change the SQL string that is associated with the delete button CButtonColumn?

I created the crud with Gii of a "view" composed with a join of 2 tables and mysql non allow to delete a record directly. So should I change the sql string associated with the delete button.

How can I do this? thanks

When you click on the Delete button you are calling actionDelete() inside of the controller class.

Inside this function can put your own SQL statements and DB query code.

But i think you need to find the way to get what you want using CActiveRecord or another Yii functionality.

thanks for the answer!

I copy here the function

public function actionDelete ($ id)


if (Yii:: app () -> request-> isPostRequest)


/ / We only allow deletion request via POST

$ this-> loadModel ($ id) -> delete ();

/ / If the AJAX request (triggered by admin on deletion grid view), We Should not redirect the browser

if (isset ($ _GET [‘ajax’]))

$ this-> redirect (isset ($ _POST [‘returnurl’])? $ _POST [‘returnurl’]: array (‘admin’));



throw new CHttpException (400, ‘Invalid request. Please do not repeat this request again.’);


The sql query should not be the default, but

DELETE FROM test. Person WHERE person. Id =?

how insert?

thanks again, very kind