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

查看:42
本文介绍了如何在Symfony 2中为数据库视图设置实体(原则)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Lets 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天全站免登陆