function tripal_core_get_property

2.x tripal_core.DEPRECATED.api.inc tripal_core_get_property($basetable, $record_id, $property, $cv_name)
3.x tripal_core.DEPRECATED.inc tripal_core_get_property($basetable, $record_id, $property, $cv_name)
1.x tripal_core_chado.api.inc tripal_core_get_property($basetable, $record_id, $property, $cv_name)

Retrieve a property for a given base table record

Parameters

$basetable: The base table for which the property should be retrieved. Thus to retrieve a property for a feature the basetable=feature and property is retrieved from featureprop

$record_id: The foriegn key field of the base table. This should be in integer.

$property: The cvterm name describing the type of properties to be retrieved

$cv_name: The name of the cv that the above cvterm is part of

Return value

An array in the same format as that generated by the function tripal_core_generate_chado_var(). If only one record is returned it is a single object. If more than one record is returned then it is an array of objects

Related topics

10 calls to tripal_core_get_property()
tripal_analysis_get_property in tripal_analysis/api/tripal_analysis.api.inc
Retrieve properties of a given type for a given analysis
tripal_contact_get_property in tripal_contact/api/tripal_contact.api.inc
Retrieve properties of a given type for a given contact
tripal_core_insert_property in tripal_core/api/tripal_core_chado.api.inc
Insert a property for a given base table. By default if the property already exists a new property is added with the next available rank. If $update_if_present argument is specified then the record will be updated if it exists rather than adding a…
tripal_core_update_property in tripal_core/api/tripal_core_chado.api.inc
Update a property for a given base table record and property name. This function should be used only if one record of the property will be present. If the property name can have multiple entries (with increasing rank) then use the function named…
tripal_featuremap_get_property in tripal_featuremap/api/tripal_featuremap.api.inc
Retrieve properties of a given type for a given featuremap

... See full list

File

tripal_core/api/tripal_core_chado.api.inc, line 2570
The Tripal Core API

Code

function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
  // get the foreign key for this property table
  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
  $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);

  // construct the array of values to be selected
  $values = array(
    $fkcol => $record_id,
    'type_id' => array(
      'cv_id' => array(
        'name' => $cv_name,
      ),
      'name' => $property,
      'is_obsolete' => 0
    ),
  );
  $results = tripal_core_generate_chado_var($basetable . 'prop', $values);
  if ($results) {
    $results = tripal_core_expand_chado_vars($results, 'field', $basetable . 'prop.value');
  }

  return $results;
}