You are here

function recommender_app_load in Recommender API 7.4

Same name and namespace in other branches
  1. 6.3 recommender.module \recommender_app_load()
  2. 7.3 recommender.module \recommender_app_load()

Get the application id from the application name.

Parameters

$app_name:

Return value

the recommender application object.

6 calls to recommender_app_load()
drush_recommender in ./recommender.drush.inc
RecommenderTestCase::testAppFunctions in ./recommender.test
recommender_app_remove in ./recommender.module
Remove the application. Usually used in calling module's hook_uninstall()
recommender_app_update in ./recommender.module
recommender_create_command in ./recommender.module

... See full list

File

./recommender.module, line 20
Providing generic recommender system algorithms.

Code

function recommender_app_load($app_name, $idonly = FALSE) {
  if (!isset($app_name) || empty($app_name)) {
    return NULL;

    // should throw an exception.
  }
  $query = db_select('recommender_app');
  if ($idonly) {
    $query
      ->addField('recommender_app', 'id');
  }
  else {
    $query
      ->fields('recommender_app');
  }
  $query
    ->condition('name', $app_name);
  $app = $query
    ->execute()
    ->fetchAssoc();
  if (!$idonly) {
    $app['params'] = json_decode($app['params'], TRUE);
    return $app;
  }
  else {
    return $app['id'];
  }
}