I’m creating a version of an existing symfony php application which is to be used as sandbox, i.e. a sort of demo version of the app.
The two apps will use separate mysql schemas on the same server.
The two schemas are identical and the sandbox schema will be dropped and recreated with data from the main app at the start of each day.
During the day, users may be created/updated in the main app and I want these changes to be reflected in the sandbox app immediately – so I need to copy changes from about three related tables whenever they’re changed in the main app.
I’ve considered creating triggers on the required tables in the main schema, but i’m having little luck finding examples of AFTER INSERT and AFTER UPDATE trigger_body that do something like.
I’ve considered modifying the Doctrine objects associated with the three tables to save via a separate Doctrine_Connection (for the sandbox dsn).
I’ve considered extending the sfDoctrineGuardPlugin in the main app to provide authentication for both apps, but this would still require a transfer of data from the three tables.
Is there any method I’ve not considered here? Which method would be best?
I solved this by doing the following in the sandbox codebase:
It’s worth noting that, in order to prevent _fixCopiedRelations from failing, I have to make sure that any related objects that exists in the main db also exist in the sandbox db, but the creation of new such objects is very limited so it’s not really a problem in this case.
I’m not particularly enamoured with the solution, but it works in this limited context and it’s good enough.