You are here

public function BotchaFormModel::getForms in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 model/botcha_form.model.inc \BotchaFormModel::getForms()
  2. 6.3 model/form/botcha.form.model.inc \BotchaFormModel::getForms()
  3. 7.2 model/botcha_form.model.inc \BotchaFormModel::getForms()

Overrides IBotchaFormModel::getForms

1 call to BotchaFormModel::getForms()
BotchaFormModel::getForm in model/form/botcha.form.model.inc

File

model/form/botcha.form.model.inc, line 21
Contains BotchaFormModel class.

Class

BotchaFormModel

Code

public function getForms($parameters = array()) {
  $forms = db_select('botcha_form', 'bf')
    ->fields('bf');
  if (!empty($parameters['forms'])) {
    foreach ((array) $parameters['forms'] as $form_id) {
      $forms
        ->condition('id', $form_id, '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 = $forms
      ->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;
}