private static function UCXF_FieldList::loadOne in Extra Fields Checkout Pane 6.2
Same name and namespace in other branches
- 7 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
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 254 - 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_query("SELECT * FROM {uc_extra_fields} WHERE field_id = %d", $arg);
}
elseif ($type == self::BY_NAME) {
$result = db_query("SELECT * FROM {uc_extra_fields} WHERE db_name = '%s'", $arg);
}
if ($result === FALSE) {
throw new UCXF_DbException(t('Failed to read from database table uc_extra_fields'));
}
self::dbResultToField($result);
}