You are here

function _variable_store_load in Variable 7

Same name and namespace in other branches
  1. 7.2 variable_store/variable_store.module \_variable_store_load()

Load realm from db store

1 call to _variable_store_load()
variable_store in variable_store/variable_store.module
Get variable store

File

variable_store/variable_store.module, line 110
Variable API module - Database storage

Code

function _variable_store_load($realm, $key) {
  $cacheid = 'variable:' . $realm . ':' . $key;
  if ($cached = cache_get($cacheid, 'cache_bootstrap')) {
    $variables = $cached->data;
  }
  else {
    $result = db_select('variable_store', 's')
      ->fields('s', array(
      'name',
      'value',
      'serialized',
    ))
      ->condition('realm', $realm)
      ->condition('realm_key', $key)
      ->execute();
    $variables = array();
    foreach ($result as $variable) {
      $variables[$variable->name] = $variable->serialized ? unserialize($variable->value) : $variable->value;
    }
    cache_set($cacheid, $variables, 'cache_bootstrap');
  }
  return $variables;
}