You are here

public static function BotchaRecipebookModel::getRecipebooks in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 model/botcha_recipebook.model.inc \BotchaRecipebookModel::getRecipebooks()
  2. 6.3 model/recipebook/botcha.recipebook.model.inc \BotchaRecipebookModel::getRecipebooks()
  3. 7.3 model/recipebook/botcha.recipebook.model.inc \BotchaRecipebookModel::getRecipebooks()
2 calls to BotchaRecipebookModel::getRecipebooks()
Botcha::getRecipebooks in controller/botcha.controller.inc
Get a list of all BOTCHA recipe book objects.
BotchaRecipebookModel::getRecipebook in model/botcha_recipebook.model.inc

File

model/botcha_recipebook.model.inc, line 14
Contains BotchaRecipebookModel class.

Class

BotchaRecipebookModel
@file Contains BotchaRecipebookModel class.

Code

public static function getRecipebooks($parameters = NULL) {
  $recipebooks = db_select('botcha_recipebook', 'brb')
    ->fields('brb');
  if (!empty($parameters['recipebooks'])) {
    foreach ((array) $parameters['recipebooks'] as $rbid) {
      $recipebooks
        ->condition('id', $rbid, '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 = $recipebooks
      ->execute()
      ->fetchAllAssoc('id');
  } 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;
}