如何在 Symfony 2 中为数据库视图设置实体(学说)

问题描述:

假设我有一个视图表.我想从中获取数据到一个实体.我可以(以及如何)创建实体类来做到这一点(不需要保存操作)?我只想显示它们.

Let's say I have a view table. And I want to get data from it to an entity. Can I (and how) create entity class to do that (no save operation needed)? I just want to display them.

查询视图没有什么特别之处——它只是一个虚拟表.以这种方式设置您的实体的表格并享受:

There is nothing special in querying a view — it's just a virtual table. Set the table of your entity this way and enjoy:

/**
 * @ORM\Entity
 * @ORM\Table(name="your_view_table")
 */
class YourEntity {
    // ...
}