You are here

public function BotchaRecipebookModel::delete in BOTCHA Spam Prevention 6.3

Same name and namespace in other branches
  1. 6.2 model/botcha_recipebook.model.inc \BotchaRecipebookModel::delete()
  2. 7.2 model/botcha_recipebook.model.inc \BotchaRecipebookModel::delete()
  3. 7.3 model/recipebook/botcha.recipebook.model.inc \BotchaRecipebookModel::delete()

Delete recipe book from the database.

Parameters

BotchaRecipebook $recipebook:

Overrides IBotchaRecipebookModel::delete

File

model/recipebook/botcha.recipebook.model.inc, line 116
Contains BotchaRecipebookModel class.

Class

BotchaRecipebookModel

Code

public function delete($recipebook) {

  // 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 {
    db_delete('botcha_recipebook_recipe')
      ->condition('rbid', $recipebook->id)
      ->execute();
    db_delete('botcha_recipebook_form')
      ->condition('rbid', $recipebook->id)
      ->execute();
    db_delete('botcha_recipebook')
      ->condition('id', $recipebook->id)
      ->execute();
  } 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);
    }
  }
}