如何在 Symfony 2 中为数据库视图设置实体(学说) [英] How to set up entity (doctrine) for database view in Symfony 2

查看:29
本文介绍了如何在 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 {
    // ...
}

这篇关于如何在 Symfony 2 中为数据库视图设置实体(学说)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆