dongyao1895 2018-05-09 13:31
浏览 49
已采纳

Symfony - 在视图中呈现所有用户的视图

I returned 10 users in a view via this fucnion..

public function getUsers()
{
    $u = $this->get('u')->getUsersBy();

    return $this->render('@Templates/admin/users.html.twig',
        array('u' => $u)
    );

}

but I need to separate it and to return ALL users via second function, but can't figure this part out.

  • 写回答

1条回答 默认 最新

  • dsgd5756 2018-05-09 15:58
    关注

    Your question is not very clear, but typically when you want to return all data from your db, you're doing something like :

        $users = $this->getDoctrine()->getRepository('YOUR/USER/ENTITY')->findAll();
        return $users;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?