When working with Doctrine2 DBAL, sometimes we work with a shared database model in which there are some support tables that we do not want in our Doctrine ORM model.
Imagine that you have an schema with following tables:
For excluding, or including, some database tables for mappings we could use 'setFilterSchemaAssetsExpression' method.
/** @var \Doctrine\DBAL\Connection $connection */ $config = $connection->getConfiguration(); // for excluding an specific table $config->setFilterSchemaAssetsExpression('/^(?!table_name_to_exclude).*$/');
When we try to generate Entities from database, with:
Doctrine ORM will only generate 'Recipes' and 'Ingredients' class entities and will exclude 'posts' and 'queue' tables.