I am building some business application and lets say there are two tables Orders
and MonthlyReports
.
These tables are not directly related (there is no relationship between them defined in ORM).
Table MonthlyReports
stores total amount of all orders and it should be updated after each purchase that is recorded in Orders
table.
I planned to use EventListener postPersist()
to automatically change the value of total amount in MonthlyReports
, but I face this problem:
- Doctrine doesn't allow inserting new entities beside using persist() method, and
MonthlyReports
can't be persisted since it is not related toOrders
table
So my question is how to create a new report at the beginning of each month, should I create some fake relationship between these tables to be able to persist new monthly report?