如何在symfony和doctrine中使用mysql视图表中的分页?

问题描述 投票:0回答:1

我有视图表添加名称,实体我的实体代码是:

/**

* @ORM\Entity(readOnly=true)
* @ORM\Table(name="adds")
*/
class Adds
{

private function __construct() {}

/**
 * @ORM\Id
 * @ORM\Column(name="id", type="string", nullable=false, unique=true)
 * @Serializer\Groups({"addList"})
 */
private $id;

/**
 * @ORM\Column(type="string")
 * @Serializer\Groups({"addList"})
 */
private $subject;

在我的控制器中我有这个:

   $em    = $this->get('doctrine.orm.entity_manager');
   $dql   = "SELECT adds FROM AppBundle:Adds adds ";
   $query = $em->createQuery($dql);
    $paginator = new Paginator($query, $fetchJoinCollection = true);

    $c = count($paginator);
    foreach ($paginator as $post) {
        $this->dumpWithHeaders($post);
    }

但总是$ post项目是[];

mysql symfony doctrine
1个回答
0
投票

我不确定,但你可以尝试这个:

  $dql   = "SELECT adds FROM App\Entity\Adds adds";

你有什么结果?

© www.soinside.com 2019 - 2024. All rights reserved.