You are here

public static function BotchaRecipeModel::save in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 model/botcha_recipe.model.inc \BotchaRecipeModel::save()
  2. 6.3 model/recipe/botcha.recipe.model.inc \BotchaRecipeModel::save()
  3. 7.3 model/recipe/botcha.recipe.model.inc \BotchaRecipeModel::save()
1 call to BotchaRecipeModel::save()
BotchaRecipe::save in controller/botcha_recipe.controller.inc

File

model/botcha_recipe.model.inc, line 41
Contains BotchaRecipeModel class.

Class

BotchaRecipeModel
@file Contains BotchaRecipeModel class.

Code

public static function save($recipe) {

  // 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 {

    // Save recipe to DB.
    db_merge('botcha_recipe')
      ->fields(array(
      'id',
      'classname',
      'title',
      'description',
    ))
      ->values(array(
      'id' => $recipe->id,
      'classname' => $recipe->classname,
      'title' => $recipe->title,
      'description' => $recipe->description,
    ))
      ->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);
    }
  }
}