Multiple and dynamic databases in doctrine 2
I checked already multiple answers on stackoverflow but couldnt find a
sufficient answer for that problem.
Imagine I have a MAIN database and multiple SLAVE databases. Based on some
information in the MAIN database I will then know which SLAVE database I
will connect to and which table I will use for my model.
As an example:
A Person entity can be connected to a database1234 database using the
table person_india or to database7834 using a table person_uk etc. Which
one I will connect to is decide on runtime and cant be configured before.
What I found so far:
I can directly bind a model to a database.table via
@Entity @Table(name="databaseName.tablename")
So Im able to join over databases. So basically Im ignoring the dbname in
the connection params for the entityManager.
Question:
How to dynamically set the information(database,table) for an entity on
the fly?
Will this affect caching?
If this is not possible in a good manner. Is there any other orm which
will provide me that kind of functionality.
Thanks in advance
No comments:
Post a Comment