dsm13698679318 2011-04-25 20:05
浏览 41
已采纳

Zend从uri获取模型ID

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

$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?

  • 写回答

1条回答 默认 最新

  • douchui3933 2011-04-25 20:18
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏