You are here

private static function UCXF_FieldList::deleteOne in Extra Fields Checkout Pane 6.2

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

Deletes one field

@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

boolean

Throws

UCXF_DbException

3 calls to UCXF_FieldList::deleteOne()
UCXF_FieldList::deleteField in class/UCXF_FieldList.class.php
Deletes an field from the database by giving the field object
UCXF_FieldList::deleteFieldById in class/UCXF_FieldList.class.php
Deletes a field by ID from the database
UCXF_FieldList::deleteFieldByName in class/UCXF_FieldList.class.php
Deletes a field by db_name from the database

File

class/UCXF_FieldList.class.php, line 379
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 deleteOne($type, $arg) {

  // Make sure the field is loaded
  self::loadOne($type, $arg);
  if ($type == self::BY_ID) {
    $field = self::getFieldById($arg);
  }
  if ($type == self::BY_NAME) {
    $field = self::getFieldByName($arg);
  }
  if (!$field) {

    // Field does not exists.
    return FALSE;
  }

  // Delete the field
  $result = db_query("DELETE FROM {uc_extra_fields} WHERE field_id = %d", $field->id);
  if ($result === FALSE || db_affected_rows() == 0) {
    throw new UCXF_DbException(t('Failed to delete a field from database table uc_extra_fields'));
  }

  // Remove field from list
  unset(self::$fields[$field->id]);

  // Give other modules a chance to react on this
  module_invoke_all('ucxf_field', $field, 'delete');
  return TRUE;
}