You are here

public static function BotchaModel::getRecipebooksRecipes in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 model/botcha.model.inc \BotchaModel::getRecipebooksRecipes()
  2. 6.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksRecipes()
  3. 7.2 model/botcha.model.inc \BotchaModel::getRecipebooksRecipes()

Overrides IBotchaModel::getRecipebooksRecipes

2 calls to BotchaModel::getRecipebooksRecipes()
BotchaModel::getRecipesRecipebooks in model/application/botcha.application.model.inc
BotchaRecipebook::getRecipes in controller/recipebook/botcha.recipebook.controller.inc
@todo BotchaRecipebook getRecipes Description.

File

model/application/botcha.application.model.inc, line 175
Contains BotchaModel class.

Class

BotchaModel

Code

public static function getRecipebooksRecipes($parameters = array()) {
  $fields = array();
  switch ($parameters['mode']) {
    case 'recipe':
      $fields[] = 'recipe_id';
      break;
    case 'recipebook':
    default:
      $fields[] = 'rbid';
      break;
  }
  $rbr = db_select('botcha_recipebook_recipe', 'brr')
    ->fields('brr', $fields);
  if (!empty($parameters['recipebooks'])) {
    $rbr
      ->condition('rbid', (array) $parameters['recipebooks'], 'IN');
  }
  if (!empty($parameters['recipes'])) {
    $rbr
      ->condition('recipe_id', (array) $parameters['recipes'], 'IN');
  }

  // Catching of PDOException helps to avoid WSOD during update use case. The
  // reason is in that form_alter is called before performing an update.
  // @see http://drupal.org/node/1828710
  try {
    $result = $rbr
      ->execute()
      ->fetchCol();
  } catch (Exception $e) {
    if ($e instanceof PDOException) {
      watchdog_exception('BOTCHA', $e, 'Please perform an update via update.php or reinstall the BOTCHA module to fix the reason of this warning! %type: !message in %function (line %line of %file).', array(), WATCHDOG_WARNING);
      $result = array();
    }
  }
  return $result;
}