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
In addition to above anwers if you are using doctrine migrations for schema update the following configuration works perfectly.
/**
* @ORM\Entity(readOnly=true)
* @ORM\Table(name="view_table_name")
*/
class YourEntity {
private function __construct() {}
}
Till here is te same as above answers. Here you need to configure doctrine not to bind schemas;
doctrine:
dbal:
schema_filter: ~^(?!view_)~
The above filter definition filters all 'view_' prefixed tables as well as views an could be extended using regex. Just make sure you have named your views with 'view_' prefix.
But doctrine:schema:update --dump-sql still shows the views, I hope they will integrate the same filter to schema update too.
I hope this solution would help some others.
Source: http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#manual-tables