0

I am using the businessHours functionality of fullcalendar to restrict certain events to my specified business hours. This works fine in my application where the events are specified as a list in my application and those that I want to constrain have the constraint: "businessHours" entry -

events: [
    {
    start: '2022-07-02 09:35:00',
    end: '2022-07-02 12:15:00',
    title: 'Mrs K Yendall',
    booking_type: '1',
    resourceId: '592',
    constraint: 'businessHours'

    }
],

However, I want to pull the events from a JSON list. This also works perfectly well by using -

events: {url: '../json_feed_bookings/json_feed_bookings.php', method: 'POST', extraParams: function(){return{param1: view2};}}, 

This method works fine until I try and output a field named 'constraint' in the MySQL SELECT statement -

$bookings_sql = "SELECT id AS id, vehicle_id AS resourceId, start_date AS start, end_date AS end, (SELECT CONCAT(title,' ',firstname,' ',surname) FROM clients WHERE id = bookings.client_id) AS title, CONCAT((SELECT CONCAT(title,' ',firstname,' ',surname) FROM clients WHERE id = bookings.client_id),': ',(SELECT hire_dt FROM view_bookings_detail WHERE booking_id = bookings.id)) AS description, IF(booking_type = 1,'#CAE1FF','#B4EEB4') AS color, booking_type AS booking_type, bh_constraint AS constraint FROM bookings";

This prevents any events from displaying on my calendar i.e. the MySQL is failing. If I remove that particular field, events are displayed, albeit without the businessHours constraint.

How do I use the businessHours constraint of specific events if I cannot pass a 'constraint' field to fullcalendar. Any advice would be appreciated.

  • 1
    Have you tried enclosing the reserved keyword in backtick? – Deadlock Jul 03 '22 at 09:20
  • SELECT `\`name\`` FROM `\`name\`` – IT goldman Jul 03 '22 at 10:26
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – ADyson Jul 03 '22 at 15:19

0 Answers0