So in my Symfony 3 project I need to create a sort of price calculator with takes 3 params: date_from, date_to, guest_number. Table in MySql looks like:
-----------------------------------------------------------------
id | date_from | date_to | people | price
-----------------------------------------------------------------
1 | 2016-01-15 | 2016-04-20 | 1 | 100
-----------------------------------------------------------------
2 | 2016-04-20 | 2016-08-15 | 1 | 200
-----------------------------------------------------------------
3 | 2016-04-20 | 2016-08-15 | 2 | 250
For example, someone choose 2016-01-01 till 2016-01-10 for 1 guest. Calculator should return 1000. And it is no big deal to create SQL statement for this
Example 2, someone choose 2016-04-15 til 2016-04-25 for 1 person.
The question is how can I build with Doctrine QueryBuilder statement which would calculate 'n' days from one period multiply price and 'n' days from another period multiply corresponding price?