If you just want to count the number of days , simply create a field.
When generating reports, avoid adding one more table to your query.
Within this field write the data as follows:
12,15,13,5,0,0,0,0,0,0,0,0
Each position represents a month, January, February, etc. ...
To add +1 day to the respective month, before recording, you have to convert the data to array using the explode function:
$aDias = explode(",",string_com_os_dias);
In the string that we use as an example, we have until the month of April completed.
An example to add another day to the month of April.
$aDias[3] += 1; //passa a 6
Before writing the data, convert the array back to string. To do this use the implode function:
$sDias = implode(",",$aDias);
This is an example if you only need to save the number of days. If you want to save the date the work was done, you need to create a table to part.
Create a new table, for example "TB_HORAS" with the fields:
- ID - int // autocomplete
- FUNCTIONAL ID - int / id of the corresponding employee corresponding to the employee table
- DATE - date // date the job was performed
- HOURS - int // number of hours
To search by month and count every day, for example, month of May for employee with ID = 5:
SELECT SUM(HORAS) FROM TB_HORAS WHERE ID_FUNCIONARIO = 5 AND DATA between '2014-05-01' AND '2014-05-31'