Doctrine2 dynamic table prefix based on logged in user in Symfony2
===

I am trying to get a multi-tenant system setup where each user has their own prefixed tables. So a solution like this http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/cookbook/sql-table-prefixes.html is a good start, but it does not allow for the prefix to be dynamically created.

Is it possible to modify the doctrine solution above to set the database prefix based on the logged in user?

Another approach would be to have a main users database and then have separate databases for the user specific tables, but I am not sure if Doctrine can handle relationships between multiple databases.

All suggestions are welcome.