gpt4 book ai didi

mysql - Symfony2 doctrine2 数组数据可用并在 Twig 文件中工作但呈现空白页面

转载 作者:行者123 更新时间:2023-11-29 00:28:21 25 4
gpt4 key购买 nike

我正在从 MySQL 数据库获取数据,但未显示在呈现的 TWIG 文件中。在 TWIG 文件中,我执行了 Twig 的 dump() 函数。它起作用了,显示了所有数据,但 TWIG 是空的。

    $em = $this->getDoctrine()->getEntityManager();
$yorumlar = $em->getRepository('SiteSiteBundle:Yorum')->find($id);

if (!$yorumlar) {
throw $this->createNotFoundException($id . ' nolu Yorum bulunamadı!');
}

return $this->render('SiteSiteBundle:Default:liste.html.twig', array(
'yorumlar' => $yorumlar
));

最佳答案

只是访问您的属性(property)。在托管实体中使用 var_dumpt、print_r 或任何转储函数可能会崩溃或使您的 PHP 服务器变慢,因为它会尝试转储您的实体原则及其所有依赖项,可能是容器...

{{ yorumlar.yourPorpertie }}

关于mysql - Symfony2 doctrine2 数组数据可用并在 Twig 文件中工作但呈现空白页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17860050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com