php - Restful rewrite update action. How to get the ID in the method when accessing the domain name/v1/product/ID after rewriting?
迷茫2017-05-16 13:01:35
0
2
444
Yii2 restful rewrites the update action. Then the question arises. When accessing api.xxxx.com/v1/product/ID after rewriting, how do you get the ID in the method?
In yii2, if your function parameter is ($id), then it will find the value of the passed parameter as id. If you do not pass it, an error will be reported
That is to say, whatever the parameters of your function are written, the $ sign will be removed to find that parameter, and it must be passed.
If you don’t want to pass parameters, write formal parameters.
This is how you get it too. It hasn’t changed I think you passed the uid directly as a parameter. You just need to use $uid directly. The description you submitted is because you did not bring $uid
It is recommended that you change actionUpdate($uid) to actionUpdate($id), so that you can press your ajax request again
In yii2, if your function parameter is ($id), then it will find the value of the passed parameter as id. If you do not pass it, an error will be reported
That is to say, whatever the parameters of your function are written, the $ sign will be removed to find that parameter, and it must be passed.
If you don’t want to pass parameters, write formal parameters.
This is how you get it too. It hasn’t changed
I think you passed the uid directly as a parameter. You just need to use $uid directly.
The description you submitted is because you did not bring $uid
It is recommended that you change actionUpdate($uid) to actionUpdate($id), so that you can press your ajax request again