Data-separation in a Symfony Multi-tenant app using Doctrine
Posted
by Prasad
on Stack Overflow
See other posts from Stack Overflow
or by Prasad
Published on 2010-04-16T07:11:29Z
Indexed on
2010/04/16
7:13 UTC
Read the original article
Hit count: 287
I am trying to implement a multi-tenant application, that is
- data of all clients in a single database
- each shared table has a tenant_id
field to separate data
I wish to achieve data separation by adding where('tenant_id = ', $user->getTenantID())
{pseudoc-code}
to all SELECT queries
I could not find any solution up-front, but here are possible approaches I am considering.
1) crude approach:
customizing all fetchAll
and fetchOne
functions in every class (I will go mad!)
2) using listeners:
possibly coding for the preDqlSelect
event and adding the 'where' to all queries
3) override buildQuery
(): could not find an example of this for front-end
4) implement contentformfilter
: again need a pointer
Would appreciate if someone could validate these & comment on efficieny, suitability. Also, if anyone has achieved multitenancy using another strategy, pl share. Thanks
© Stack Overflow or respective owner