From c707f90c97a9f40154a8608be9ac060649db48fd Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 27 May 2016 10:51:49 +1000 Subject: [PATCH] change to node load --- booking.regn_node.inc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/booking.regn_node.inc b/booking.regn_node.inc index 4f5ee5c..e8487d1 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -101,6 +101,44 @@ function _booking_node_create_mysqlview() function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE) { global $event; + + //filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id + if (! is_null($node_ids)) + { + //$query = db_query("SELECT * FROM booking_person_view WHERE nid IN :nid", array(':nid' => $node_ids)); + $query = db_query("SELECT * FROM booking_person_view WHERE nid IN (:nid)", array(':nid' => implode(',', $node_ids))); + //$query->condition('p.nid', $node_ids, 'IN'); + } + else + { + $query = db_query("SELECT * FROM booking_person_view"); + //$query->condition('p.booking_eventid', $event->eid, '='); + } + + watchdog('booking_debug', "
Loading node query:\n@info
", array('@info' => print_r( (string)$query, true))); + + //get the query result as either an associative array + if ($fetchAssoc == TRUE) + { + $result = $query->execute()->fetchAllAssoc('nid'); + } + else + { + $result = $query->execute(); + } + + watchdog('booking', "
Loading node query output:\n@info
", array('@info' => print_r( $result, true))); + return $result; +} + +/** + * Function to query the database for the complete object representing a registration + * + * @param $node_ids - a list of node IDs to query for + * @return list of objects + */ +function booking_load_query_old($node_ids = NULL, $fetchAssoc = FALSE) +{ //$studygroup_count = variable_get('booking_studygroup_count','0'); $studygroups = array();