Symfony3从数据库中获取错误的数据

时间:2016-12-27 16:11:27

标签: jenkins docker doctrine twig symfony

我有一个symfony 3项目,可以在我的本地机器上正常工作但是在docker上清理并清除缓存后,将777权限交给var文件夹,项目工作但数据错误。 这是例如的控制方法:

/**
 * @Route("/post/index",name="postindex")
 */
public function indexAction()
{
    $Posts = $this->getDoctrine()->getRepository('AppBundle\Entity\Post')->findAll();
    return $this->render('AppBundle:Post:index.html.twig', array('posts' => $Posts));
}

这是树枝模板

> {% extends "::base.html.twig" %} {% block title %}List Post{% endblock
> %} {% block body %}
>     <section class="firstsection">
>         <div class="container">
>             <h2>Posts</h2>
>             <table class="table  table-bordered">
>                 <tr class="active">
>                     <td class="text-bold">Title</td>
>                     <td class="text-bold">Body</td>
>                     <td class="text-bold">created At</td>
>                     <td class="text-bold">update dAt</td>
>                     <td class="text-bold">Action</td>
>                 </tr>
>                 {% for post in posts %}
>                     <tr>
>                         <td>{{ post.title }}</td>
>                         <td>{{ post.body }}</td>
>                         <td>{{ post.createdAt|date("m/d/Y") }}</td>
>                         <td>{{ post.updatedAt|date("m/d/Y") }}</td>
>                         <td>
>                             <ul>
>                                 <li><a href="{{ path('postshow', {'id': post.id}) }}">View</a></li>
>                                 <li><a href="{{ path('postupdate', {'id': post.id}) }}">Edit</a></li>
>                                 <li><a href="{{ path('postdelete', {'id': post.id}) }}">Delete</a></li>
>                             </ul>
>                         </td>
>                     </tr>
>                 {% endfor %}
>             </table>
>         </div>
>     </section> {% endblock %}

这是结果: enter image description here

这就是我在帖子表中的内容

enter image description here

有什么帮助吗? 抱歉英语。

1 个答案:

答案 0 :(得分:0)

您正在为部署版本使用不同的数据库

相关问题