Zend get model id from uri
I'm getting trying to get familiar with Zend and have a question that's probably a no-brainer, but so far haven't been able to find the answer via Google or SO.
What is the default method of passing a model's ID via the URI. I've tried
http://myurl/controller/edit/1
where 1 is the corresponding primary key in the database, but am unable to get the id in the editAction() method with
$开发者_JAVA技巧request = $this->getRequest();
$id = $request->getParam('id');`
I'm guessing there's a simple configuration item I'm missing. Could someone kindly point me in the right direction?
The default routes in ZF look like
[/<module>]/<controller>/<action>/<param1>/<value1>/<param2>/<value2>
So, in your example, you'd want something like:
/controller/edit/id/1
If you want to do-away with the /id/ bit, you'll need to define a custom route.
精彩评论