atr_review_load_multiple

Versions
6.1
atr_review_load_multiple($rids)

Load multiple reviews.

Parameters

$rids An array with the RIDs of the reviews to load.

Return value

An array with ATRReview objects.

Code

atr/atr.module, line 430

<?php
function atr_review_load_multiple($rids) {
  // Get previously loaded reviews from the static cache.
  $reviews_cache = array();
  foreach ($rids as $i => $rid) {
    if($review = atr_cache_static("review_$rid")) {
      $reviews_cache[$rid] = $review;
      unset($rids[$i]);
    }
  }

  // Get the remaining reviews from the DB.
  $reviews_db = array();
  if ($rids) {
    $placeholders = db_placeholders($rids);
    $methods = array();
    $result = db_query("SELECT method FROM {atr_review_method} WHERE rid in ($placeholders)", $rids);
    while ($method = db_result($result)) {
      $methods[] = $method;
    }
    $result = db_query("SELECT * FROM {atr_review} WHERE rid in ($placeholders)", $rids);
    while ($review_data = db_fetch_object($result)) {
      $rid = $review_data->rid;
      $review = new ATRReview($review_data->title, $review_data->language, $methods, $review_data->string_count, $review_data->word_count, $review_data->timestamp, $rid);
      $reviews_db[$rid] = $review;
      atr_cache_static("review_$rid", $review);
    }
    foreach (module_implements('atr_review_load') as $module) {
      call_user_func($module . '_atr_review_load', $reviews_db);
    }
  }

  return $reviews_cache + $reviews_db;
}
?>