我有视图表添加名称,实体我的实体代码是:
/**
* @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项目是[];
我不确定,但你可以尝试这个:
$dql = "SELECT adds FROM App\Entity\Adds adds";
你有什么结果?