use mysql view for loading nodes
This commit is contained in:
@@ -92,6 +92,17 @@ function _booking_node_create_mysqlview()
|
|||||||
watchdog('booking_debug', "<pre>Booking Person View creation result:\n@info</pre>", array('@info' => print_r($viewquery, true)));
|
watchdog('booking_debug', "<pre>Booking Person View creation result:\n@info</pre>", 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
|
* 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)
|
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
|
//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))
|
if (! is_null($node_ids)) {
|
||||||
{
|
$nid_string = implode(',', array_map('_booking_quote_string', $node_ids));
|
||||||
//$query = db_query("SELECT * FROM booking_person_view WHERE nid IN :nid", array(':nid' => $node_ids));
|
$query_string = "SELECT * FROM {booking_person_view} WHERE nid IN ( " . $nid_string . " )";
|
||||||
$query = db_query("SELECT * FROM booking_person_view WHERE nid IN (:nid)", array(':nid' => implode(',', $node_ids)));
|
//watchdog('booking_debug', "<pre>Loading node query:\n@info</pre>", array('@info' => print_r($query_string, true)));
|
||||||
//$query->condition('p.nid', $node_ids, 'IN');
|
$result = db_query($query_string)->fetchAllAssoc('nid');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
$result = db_query("SELECT * FROM {booking_person_view}")->fetchAllAssoc('nid');
|
||||||
$query = db_query("SELECT * FROM booking_person_view");
|
|
||||||
//$query->condition('p.booking_eventid', $event->eid, '=');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog('booking_debug', "<pre>Loading node query:\n@info</pre>", 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', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user