【问题标题】:How to use {% for in %} symfony?如何使用 {% for in %} symfony?
【发布时间】:2016-07-23 09:02:31
【问题描述】:

我的问题是,当我使用循环时,里面的数据不显示, 这是我使用循环的代码,即使“mes Boutiques”也不显示, , only "shirts & tops" show up

and this function where im calling this template in the controller

【问题讨论】:

    标签: css symfony templates view controller


    【解决方案1】:

    您的模板看起来不错。问题可能出在可能返回 DQL 的存储库方法中:表示 Doctrine 中查询的字符串。

    我怀疑你的实体方法中有这样的方法:

    // retrieve the DQL string of what was defined in QueryBuilder
    $dql = $qb->getDql();
    

    所以你需要用这样的东西替换:

    // retrieve the associated Query object with the processed DQL
    $query = $qb->getQuery();
    
    // Execute Query
    $result = $query->getResult();
    
    return $result;
    

    希望有帮助

    【讨论】:

      【解决方案2】:

      您的函数 affichDQL() 一定有问题,您应该在控制器中使用 dump($enseignes); 测试结果看看你是否有结果。您也可以使用 {% dump(enseignes) %}

      在您的树枝中添加检查

      【讨论】:

      • 谢谢大家,问题出在afficheDQL(),是的,没有数据返回!
      猜你喜欢
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 2011-10-31
      相关资源
      最近更新 更多