Helo, I am trying to get the products available between two dates through calendar table where I have relation with the product.
I put the data of my table:
I understand that if I do a foreach and I'm checking day by day I can get it, but I do not want it that way, I want to do it correctly with mysql
This is the query that I am currently executing and does not give me the expected results. this is name the my page
$start_date = fecha_mysql_slash($this->input->get('start_date'));
$end_date = fecha_mysql_slash($this->input->get('end_date'));
$calendars = new Calendar();
$calendars->select("*")
->where('day BETWEEN "'.$start_date.'" AND "'.$newEndDate.'" and availability > 0')
->include_related("producto",NULL,TRUE,TRUE)
->group_by("producto_id")
->get()->all;
Now I will try to explain to me, through a form I get the start date and also the end date, so I have to check in the calendar table from start date to end date if exists in the field "day" and also Which has availability greater than 0., well with this query I can not get it.
Currently there is no error, the problem is that I get products, when on the dates that I indicate does not exist in the table and field "day"
For example I make the query through the dates 2017-03-13 and 2017-03-25, the problem that I think I do not understand because I get the product id, when from 2017-03-13 there are no records for these product.
I hope you can help me,
thank you very much.