I'm building a SaaS calendar with MySQL & PHP.
The front-end javascript calendar lib is fullcalendar(monthly view) http://fullcalendar.io/
I have a mysql data table named events
like this:
The BODY_START
and BODY_END
is using unix_timestamp.
Then in my PHP code, I built a query helper that generate a SQL like:
"SELECT * FROM `" . $this->_tableName . "` WHERE `ID_ACCOUNT` = '$_id_account' AND (( `BODY_START` >= 1424649600 AND `BODY_START` <= 1428278400 ) OR (`BODY_END` >= 1424649600 AND `BODY_END` <= 1428278400))";
The start and end timestamp params provided by the fullcalendar.
There is a question:
if the event is crossing the current month, it will not be shown.
example:
f8a58d0c8280db2340863a1ac7aa60b0
e576c22ce89f38ee422ec818807b99b8
test_event
1422720000
1428422400
0
1422845255
0
0
If you do the query, this event will not show.
how can i fix this? Thanks.
If I understand you correctly, simplify your query to be (in pseudo code):
BODY_START <= month_end and BODY_END >= month_start
Your original query query above requires that events must either start or end during the month, but that's not actually what you want - you want any event that exists for any part of the month.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.