function chado_delete_property
2.x tripal_core.chado_general.api.inc | chado_delete_property($record, $property) |
3.x tripal_chado.property.api.inc | chado_delete_property($record, $property) |
Deletes a property for a given base table record using the property name.
Parameters
$record: An associative array used to identify the record to which the property should be deleted. The following keys must be used: -table: The base table for which the property should be deleted. Thus to update a property for a feature the base_table=feature. -id: The primary key value of the base table. The property will be deleted from the record that matches this id. -prop_id: The primary key in the [table]prop table to be deleted. If this value is supplied then the 'table' and 'id' keys are not needed.
$property: An associative array used to specify the property to be updated. It can contain the following keys. The keys must be specified to uniquely identify the term to be applied. If the options identify more than one CV term then an error will occur. -type_name: The cvterm name to be selected. -type_id: The cvterm_id of the term to be selected. -cv_id: The cv_id of the CV that contains the term. -cv_name: The name of the CV that contains the term. -value: The specific value for the property. -rank: The specific rank for the property.
Return value
Return TRUE on successful deletion and FALSE otherwise.
Related topics
- TaxonomyImporter::addProperty in tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc - Adds a property to an organism node.
- tripal_analysis_delete_property in legacy/
tripal_analysis/ api/ tripal_analysis.DEPRECATED.inc - tripal_contact_delete_property in legacy/
tripal_contact/ api/ tripal_contact.DEPRECATED.inc - tripal_core_delete_property in legacy/
tripal_core/ api/ tripal_core.DEPRECATED.inc - tripal_featuremap_delete_property in legacy/
tripal_featuremap/ api/ tripal_featuremap.DEPRECATED.inc
- tripal_analysis_delete_property in legacy/
tripal_analysis/ api/ tripal_analysis.DEPRECATED.inc - tripal_contact_delete_property in legacy/
tripal_contact/ api/ tripal_contact.DEPRECATED.inc - tripal_core_delete_property in legacy/
tripal_core/ api/ tripal_core.DEPRECATED.inc - tripal_featuremap_delete_property in legacy/
tripal_featuremap/ api/ tripal_featuremap.DEPRECATED.inc - tripal_feature_analysis_delete_property in legacy/
tripal_feature/ api/ tripal_feature.DEPRECATED.inc
File
- tripal_chado/
api/ tripal_chado.property.api.inc, line 458 - Provides an application programming interface (API) to manage data withing the Chado database.
Code
function chado_delete_property($record, $property) {
$base_table = array_key_exists('table', $record) ? $record['table'] : '';
$base_id = array_key_exists('id', $record) ? $record['id'] : '';
$prop_id = array_key_exists('prop_id', $record) ? $record['prop_id'] : '';
$type_name = array_key_exists('type_name', $property) ? $property['type_name'] : '';
$type_id = array_key_exists('type_id', $property) ? $property['type_id'] : '';
$cv_name = array_key_exists('cv_name', $property) ? $property['cv_name'] : '';
$cv_id = array_key_exists('cv_id', $property) ? $property['cv_id'] : '';
$value = array_key_exists('value', $property) ? $property['value'] : '';
$rank = array_key_exists('rank', $property) ? $property['rank'] : 0;
// Build the values array for checking if the CVterm exists.
$type = array();
if ($cv_id) {
$type['cv_id'] = $cv_id;
}
if ($cv_name) {
$type['cv_id'] = array(
'name' => $cv_name,
);
}
if ($type_name) {
$type['name'] = $type_name;
}
if ($type_id) {
$type['cvterm_id'] = $type_id;
}
// Make sure the CV term exists.
$options = array();
$term = chado_select_record('cvterm', array('cvterm_id'), $type, $options);
if (!$term or count($term) == 0) {
tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_delete_property: " .
"Cannot find the term described by: %property.",
array('%property' => print_r($property, TRUE)));
return FALSE;
}
if (count($term) > 1) {
tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_delete_property: " .
"Multiple terms found. Cannot add the property. Property was described " .
"by: %property.",
array('%property' => print_r($property, TRUE)));
return FALSE;
}
// Get the foreign key for this property table.
$table_desc = chado_get_schema($base_table . 'prop');
$fkcol = key($table_desc['foreign keys'][$base_table]['columns']);
// If we have the unique property_id, make sure to use it in the match to
// ensure we get the exact record. Doesn't rely on there only being one
// property of that type.
if ($prop_id) {
$property_pkey = $table_desc['primary key'][0];
$match = array(
$property_pkey => $prop_id
);
}
// Construct the array that will match the exact record to update.
else {
$match = array(
$fkcol => $record_id,
'type_id' => $type,
);
}
return chado_delete_record($base_table . 'prop', $match);
}