【问题标题】:pass data from the action layer to the model将数据从动作层传递到模型
【发布时间】:2010-05-25 12:42:35
【问题描述】:

我在 LocationTable.class.php 中有一个 DQL 查询

对于这个查询,我需要一个通过 URL 传递给操作的 ID ?id=2

在操作中,我可以使用 $request->getParamater('id') 来访问它,但是我怎样才能使我的查询所在的模型也可以使用它呢?我需要它作为 where 子句。

【问题讨论】:

    标签: model-view-controller symfony1 doctrine dql


    【解决方案1】:

    当你从动作中调用函数时,将变量传递给它:

    在行动:

    Doctrine::getTable('Location')->yourFunction($request->getParameter('id'));
    

    在位置表中:

    public function yourFunction($id)
    {
      ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-03
      • 2019-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多