开发者

Zend get model id from uri

开发者 https://www.devze.com 2023-02-28 20:26 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消