diff --git a/booking.regn_node.inc b/booking.regn_node.inc index e8487d1..b10d0dc 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -92,6 +92,17 @@ function _booking_node_create_mysqlview() watchdog('booking_debug', "
Booking Person View creation result:\n@info
", array('@info' => print_r($viewquery, true))); } +/** + * Function to add single quote marks around a string + * @see booking_load_query + * + * @param $input - string to add quote marks around + * @return quoted string + */ +function _booking_quote_string($input) { + return sprintf("'%s'", $input); +} + /** * Function to query the database for the complete object representing a registration * @@ -100,33 +111,17 @@ 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'); + if (! is_null($node_ids)) { + $nid_string = implode(',', array_map('_booking_quote_string', $node_ids)); + $query_string = "SELECT * FROM {booking_person_view} WHERE nid IN ( " . $nid_string . " )"; + //watchdog('booking_debug', "
Loading node query:\n@info
", array('@info' => print_r($query_string, true))); + $result = db_query($query_string)->fetchAllAssoc('nid'); } - else - { - $query = db_query("SELECT * FROM booking_person_view"); - //$query->condition('p.booking_eventid', $event->eid, '='); + else { + $result = db_query("SELECT * FROM {booking_person_view}")->fetchAllAssoc('nid'); } - - 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; }