function variable_get

7.x db.inc variable_get($name, $default_value = "")
6.x db.inc variable_get($name, $default_value = "")
4.x db.inc variable_get($name, $default_value = "")
5.x db.inc variable_get($name, $default_value = "")

Get a variable from the database. We will first look in our GLOBALS array, to see that it hasn't already been retrieved this page load.

Parameters

string $name:

mixed $default_value:

Return value

mixed

116 calls to variable_get()
admin_add_degree_form in modules/admin/admin.degrees.inc
This form lets the user add a degree to the database.
admin_add_degree_form_submit in modules/admin/admin.degrees.inc
Submit handler for the add_degree_form.
admin_apply_draft_changes_form_submit in modules/admin/admin.module
Handles the actual moving of draft courses into production.
admin_apply_draft_changes_form_validate in modules/admin/admin.module
Before we apply changes, make sure the password is correct.
admin_cron in modules/admin/admin.module
hook_cron

... See full list

File

includes/db.inc, line 887
This file contains mostly db shortcuts.

Code

function variable_get($name, $default_value = "") {

  $val = null;
  // First, check in our GLOBALS array, like a cache...
  if (isset($GLOBALS ["fp_system_settings"][$name])) {
    $val = $GLOBALS ["fp_system_settings"][$name];
  }
  else {
    // Not found-- look in the database for it.
    $res = db_query("SELECT value FROM variables
                           WHERE name = ? ", array($name));
    $cur = db_fetch_array($res);
    @$val = unserialize($cur ["value"]);

    // Save back to our cache...
    $GLOBALS ["fp_system_settings"][$name] = $val;

  }


  if (!$val) {
    $val = $default_value;
  }

  // We must have this down here again, just in case what got stored in the GLOBALS
  // array was this placeholder.  This can happen, because the settings file doesn't do
  // this check when assembling this variable on page load.  It's something that needs
  // to be fixed.
  if ($val === "BOOLEAN_FALSE_PLACEHOLDER") {
    $val = FALSE;
  }

  if ($val === "NULL_PLACEHOLDER") {
    $val = NULL;
  }

  return $val;
}