Last Updated: February 25, 2016
· xfornesa

Doctrine, tell which tables to work with

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:

  • recipes
  • ingredients
  • posts
  • queue

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

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.