コード例 #1
0
 /**
  * Get array of appointments.
  *
  * @return array
  * [
  *  staff_id => [ appointment_data ],
  *  ...
  * ]
  */
 private function _getBookings()
 {
     /** @var WPDB $wpdb */
     global $wpdb;
     $result = array();
     $rows = $wpdb->get_results($wpdb->prepare("SELECT `a`.*, `ss`.`capacity`, COUNT(*) AS `number_of_bookings`\n                FROM `ab_customer_appointment` `ca`\n                LEFT JOIN `ab_appointment` a ON `a`.`id` = `ca`.`appointment_id`\n                LEFT JOIN `ab_staff_service` `ss` ON `ss`.`staff_id` = `a`.`staff_id` AND `ss`.`service_id` = `a`.`service_id`\n             WHERE `a`.`staff_id` IN ({$this->_staffIdsStr}) AND `a`.`start_date` >= %s\n             GROUP BY `a`.`start_date`, `a`.`staff_id`, `a`.`service_id`", $this->_userData->getRequestedDateFrom()));
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $result[$row->staff_id][] = $row;
         }
     }
     return $result;
 }