function tripal_core_update_property_by_id
2.x tripal_core.DEPRECATED.api.inc | tripal_core_update_property_by_id($basetable, $record_id, $property,
$cv_name, $value) |
3.x tripal_core.DEPRECATED.inc | tripal_core_update_property_by_id($basetable, $record_id, $property,
$cv_name, $value) |
1.x tripal_core_chado.api.inc | tripal_core_update_property_by_id($basetable, $record_id, $property,
$cv_name, $value) |
Update a property for a given base table record. This function should be used if multiple records of the same property will be present. Also, use this function to change the property name of an existing property.
Parameters
$basetable: The base table for which the property should be updated. The property table is constructed using a combination of the base table name and the suffix 'prop' (e.g. basetable = feature then property tabie is featureprop).
$record_id: The primary key of the base table. This should be in integer. For example, if the basetable is 'feature' then the $record_id should be the featureprop_id
$property: The cvterm name of property to be updated
$cv_name: The name of the cv that the above cvterm is part of
$value: The value of the property to be inserted (can be empty)
Return value
Return True on Update/Insert and False otherwise
Related topics
- tripal_feature_analysis_update_property_by_id in tripal_feature/
api/ tripal_feature.api.inc - Update a property for an analysis feature using the analysisfeatureprop_id.
- tripal_feature_update_property_by_id in tripal_feature/
api/ tripal_feature.api.inc - Update a given feature property using the featureprop_id
File
- tripal_core/
api/ tripal_core_chado.api.inc, line 2784 - The Tripal Core API
Code
function tripal_core_update_property_by_id($basetable, $record_id, $property,
$cv_name, $value) {
// get the primary key for this property table
$table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
$pkcol = $table_desc['primary key'][0];
// construct the array that will match the exact record to update
$match = array(
$pkcol => $record_id,
);
// construct the array of values to be updated
$values = array(
'type_id' => array(
'cv_id' => array(
'name' => $cv_name,
),
'name' => $property,
),
'value' => $value,
);
return tripal_core_chado_update($basetable . 'prop', $match, $values);
}