0

I'm starting my first project with Symfony.

I'm trying to figure if what I want/need is feasible.

I use Doctrine ORM with 2 entity manager, one for the app itself with MySQL database and one for the users data that are SQLite databases.

I want that when someone access something like this : http://example.com/user1/show the apps retrieve the name of the database for user1 and change the entity manager database path and name to the user's database (previously uploaded).

I need a direction where and what to check/read about how to make this possible (if it is) or any example.

Maybe my approach need to be changed too. Any input will be appreciate.

  • Just checking if I got it right - You want to create separate database for each user? Is there a reason why not to store all users in one DB? – Jan Rydrych Mar 11 '17 at 17:56
  • The user's database is create from a desktop software that user must buy from an another vendor. So everyone who want to use my site will have to first upload that database. This is why I can't have everything in one database. – Patrick Pellegrino Mar 11 '17 at 18:05
  • Out of the box, Symfony caches all the database access information and does a bit of optimizing. Selecting a database based on the route means you will need to roll up your sleeves and make the database connection yourself. I have never seen what I consider to be a good example of doing this you could search around a bit. – Cerad Mar 12 '17 at 14:03
  • I've read about CompilerPass this morning. I'll test if possible with that. Any result will be posted back in any way. – Patrick Pellegrino Mar 12 '17 at 14:05
  • @PatrickPellegrino - CompilerPass is a dead end for what you want. Passes are part of the cache generating system and cannot be used for request based customization. – Cerad Mar 13 '17 at 17:51
  • @cerad this is what I figure early in my test! – Patrick Pellegrino Mar 13 '17 at 17:53

1 Answers1

0

When the user will upload the DB file, you should definitely make some integrity check of it (security and stability reasons), right? And when you'll have the data processed, you're only one step from migrating them to your app's SQL DB. And thinking bit further - consider if some needs of data views/manipulations across multiple users can occur. If so, the SQL DB is way more efficient than handling hundreds or thousands of SQLite files.

Jan Rydrych
  • 2,188
  • 2
  • 13
  • 18
  • I've already thinking about that but for other consideration I don't want really use that approach (users can download back the SQLite databases with modified data). If it came to be the only way, I'll go with it but it's a kind of last resort right now. Data will not be shared between users. – Patrick Pellegrino Mar 12 '17 at 13:43