variable_get

5.x db.inc variable_get($name, $default_value = "")
4.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

unknown_type $name:

unknown_type $default_value:

Return value

unknown

47 calls to variable_get()
admin_advising_settings_form in modules/admin/admin.module
This is a systems settings form, which lets the user edit advising variabled for FlightPath.
admin_apply_draft_changes_form_submit in modules/admin/admin.module
Handles the actual moving of draft courses into production.
admin_display_main in modules/admin/admin.module
This is the "main" page for the admin module. It's what the user first sees when the click to go to the Admin page.
admin_duplicate_year_form_submit in modules/admin/admin.module
This function should perform the actual copy of data!
admin_urgent_message_form in modules/admin/admin.module
Meant to be fed into "fp_system_settings_form()", this function returns an array which will automatically save values to our "variables" table.

... See full list

File

includes/db.inc, line 311
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 = '?' ", $name);
    $cur = db_fetch_array($res);
    $val = unserialize($cur["value"]);

    if ($val === "BOOLEAN_FALSE_PLACEHOLDER") {
      $val = FALSE;
    }

    // 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;
  }

  return $val;
}