You are here

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

Same name and namespace in other branches
  1. 6.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksRecipes()
  2. 7.2 model/botcha.model.inc \BotchaModel::getRecipebooksRecipes()
  3. 7.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksRecipes()
3 calls to BotchaModel::getRecipebooksRecipes()
Botcha::getRecipebook in controller/botcha.controller.inc
Gets a recipe book from cache. If it does not exists in cache - gets from database. If it does not exists there also - returns new recipe book or BotchaRecipebookNone depending on input parameter.
BotchaModel::getRecipesRecipebooks in model/botcha.model.inc
BotchaRecipebookAbstract::getRecipes in controller/botcha_recipebook.controller.inc
@todo BotchaRecipebook getRecipes Description.

File

model/botcha.model.inc, line 64

Class

BotchaModel

Code

public static function getRecipebooksRecipes($parameters = array()) {
  $key = '';
  switch ($parameters['mode']) {
    case 'recipe':
      $key = 'recipe_id';
      break;
    case 'recipebook':
    default:
      $key = 'rbid';
      break;
  }

  // Parameters to pass to the build query mechanism.
  $pars = array();
  $pars['fields'] = array();
  if (!empty($parameters['recipebooks'])) {
    $pars['conditions'][BOTCHA_MODEL_OP_IN]['rbid'] = (array) $parameters['recipebooks'];
  }
  if (!empty($parameters['recipes'])) {
    $pars['conditions'][BOTCHA_MODEL_OP_IN]['recipe_id'] = (array) $parameters['recipes'];
  }

  // Execute query and fetch the result.
  $query = BotchaModel::buildQuery(BOTCHA_MODEL_TYPE_SELECT, 'botcha_recipebook_recipe', $pars);
  $result_query = BotchaModel::getQueryResult($query['query'], $query['query_subs']);
  $result = BotchaModel::fetchQueryResult($result_query, $key);
  return $result;
}