Yii - inside automatically generated controller : where do the $id come from?
a quick question to you about the auto-generated Yii code: in the controller, the functions like this:
public function actionDelete($id)
where do they get that $id from? i开发者_高级运维s it throguh $_POST or $_GET or is it something totally different? I'm struggling to make an ajax 'delete something' button and i'm stuck at creating an ajax link to post the 'id' of that something
that is the name of the GET variable, so your action might be /myController/myAction?id=4, which is equivalent to /myController/myAction/id/4
...and 4 would be the value passed to the method.
you can add another parameter to the method, and you will have to include that variable/value in your querystring.
Yii didn't always have this, it was added in 1.12 maybe.
You can get the same value by calling $_GET['id']
This is called "Action Parameter Binding" in Yii
Have a look at this link, search for Action Parameter Binding
http://www.yiiframework.com/doc/guide/1.1/en/basics.controller
精彩评论