You are here

public static function UCXF_Value::load_list in Extra Fields Checkout Pane 7

Same name and namespace in other branches
  1. 6.2 class/UCXF_Value.class.php \UCXF_Value::load_list()

Loads a list of values from database

Parameters

int $element_id: id of element, order_id or uc_addresses id

int $element_type: type of element: order or address

Return value

array

3 calls to UCXF_Value::load_list()
UCXFApiTestCase::testUCXF_Value in ./uc_extra_fields_pane.test
Test if UCXF_Value behaves as excepted.
UCXFTestCase::checkValuesInDatabase in ./uc_extra_fields_pane.test
Test if these values appear in the database.
uc_extra_fields_pane_value_list_load in ./uc_extra_fields_pane.module
uc_extra_fields_pane_value_list_load() Loads a list of values from database

File

class/UCXF_Value.class.php, line 284
Contains the UCXF_Value class.

Class

UCXF_Value
This class is used to keep track of all field values currently loaded.

Code

public static function load_list($element_id, $element_type) {

  // Check if value list has already been loaded
  if (isset(self::$loaded_lists[$element_id][$element_type]) && isset(self::$loaded_values[$element_id][$element_type]) && self::$loaded_lists[$element_id][$element_type]) {
    return self::$loaded_values[$element_id][$element_type];
  }
  $query = db_select('uc_extra_fields_values', 'ucxf_values');
  $query
    ->innerJoin('uc_extra_fields', 'ucxf_fields', 'ucxf_values.field_id = ucxf_fields.field_id');
  $result = $query
    ->condition('ucxf_values.element_id', $element_id)
    ->condition('ucxf_values.element_type', $element_type)
    ->fields('ucxf_values', array(
    'element_id',
    'element_type',
    'field_id',
    'value',
  ))
    ->fields('ucxf_fields', array(
    'db_name',
  ))
    ->execute();
  if ($result) {
    self::dbResultToValue($result);
  }

  // Check if we have a result now
  if (isset(self::$loaded_values[$element_id][$element_type])) {

    // Set flag that the list is loaded.
    self::$loaded_lists[$element_id][$element_type] = TRUE;

    // Return the loaded list.
    return self::$loaded_values[$element_id][$element_type];
  }
  return array();
}