function tripal_bulk_loader_update_constant

2.x tripal_bulk_loader.constants.inc tripal_bulk_loader_update_constant($nid, $group_id, $table, $field, $record_id, $field_id, $value)
3.x tripal_bulk_loader.constants.inc tripal_bulk_loader_update_constant($nid, $group_id, $table, $field, $record_id, $field_id, $value)
1.x tripal_bulk_loader.constants.inc tripal_bulk_loader_update_constant($nid, $group_id, $table, $field, $record_id, $field_id, $value)

Inserts/Updates a tripal bulk loading job constant

Parameters

$nid: The node ID of the the tripal bulk loading job the constant is associated with

$table: The chado table the constant is associated with

$field: The chado field the constant is associated with

$record_id: The index in the template array for this record

$field_id: The index in the template array for this field

NOTE: $template_array[$record_id]['table'] = $table and $template_array[$record_id]['fields'][$field_id]['field'] = $field both are included as a means of double-checking the constant still is still in thesame place in the template array. For example, that the template was not edited and the records moved around after the job was submitted but before it was run.

Return value

On success it returns the object (with primary key if inserted); on failure it returns FALSE

Related topics

2 calls to tripal_bulk_loader_update_constant()
tripal_bulk_loader_edit_constant_set_form_submit in tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc
Edit constants in the current constant set
tripal_bulk_loader_set_constants_form_submit in tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc
Insert/update the constants associated with this node

File

tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc, line 33
Manages the constants form added to the tripal bulk loader node form

Code

function tripal_bulk_loader_update_constant($nid, $group_id, $table, $field, $record_id, $field_id, $value) {

  $record = array(
    'nid' => $nid,
    'group_id' => $group_id,
    'chado_table' => $table,
    'chado_field' => $field,
    'record_id' => $record_id,
    'field_id' => $field_id,
    'value' => $value
  );

  // Check to see if already exists
  $exists = db_select('tripal_bulk_loader_constants', 'c')
    ->fields('c', array('constant_id'))
    ->condition('nid', $record['nid'])
    ->condition('record_id', $record['record_id'])
    ->condition('field_id', $record['field_id'])
    ->condition('group_id', $record['group_id'])
    ->execute();
  $exists = $exists->fetchObject();
  if (!isset($exists)) {
    $record['constant_id'] = $exists->constant_id;
    $status = drupal_write_record('tripal_bulk_loader_constants', $record, 'constant_id');
    if ($status) {
      return $record;
    }
    else {
      return FALSE;
    }
  }
  else {

    $status = drupal_write_record('tripal_bulk_loader_constants', $record);
    if ($status) {
      return $record;
    }
    else {
      return FALSE;
    }
  }
}