You are here

private static function UCXF_FieldList::loadOne in Extra Fields Checkout Pane 7

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

Load a single field if not already loaded

No database call is done in these cases:

  • Field is already loaded

@access private @static

Parameters

int $type: Type of the argument given, can be the field id (BY_ID) or the field db_name (BY_NAME)

mixed $arg: Either the field id or the field db_name

Return value

void

Throws

UCXF_DbException

3 calls to UCXF_FieldList::loadOne()
UCXF_FieldList::deleteOne in class/UCXF_FieldList.class.php
Deletes one field
UCXF_FieldList::getFieldByID in class/UCXF_FieldList.class.php
Get a single field by ID
UCXF_FieldList::getFieldByName in class/UCXF_FieldList.class.php
Get a single field by name

File

class/UCXF_FieldList.class.php, line 225
Contains the UCXF_FieldList class.

Class

UCXF_FieldList
This class is used to keep track of all loaded fields in one request. It's also used as a central place to request fields.

Code

private static function loadOne($type, $arg) {

  // Reasons to skip out early
  if (self::$allLoaded) {
    return;
  }
  if ($type == self::BY_ID && isset(self::$fields[$arg])) {
    return;
  }
  if ($type == self::BY_NAME && self::findByName($arg)) {
    return;
  }
  if ($type == self::BY_ID) {
    $result = db_select('uc_extra_fields')
      ->condition('field_id', $arg)
      ->fields('uc_extra_fields')
      ->orderBy('weight')
      ->execute();
  }
  elseif ($type == self::BY_NAME) {
    $result = db_select('uc_extra_fields')
      ->condition('db_name', $arg)
      ->fields('uc_extra_fields')
      ->orderBy('weight')
      ->execute();
  }
  if ($result === FALSE) {
    throw new UCXF_DbException(t('Failed to read from database table uc_extra_fields'));
  }
  self::dbResultToField($result);
}