function chado_project_insert
2.x tripal_project.chado_node.inc | chado_project_insert($node) |
3.x tripal_project.chado_node.inc | chado_project_insert($node) |
1.x tripal_project.module | chado_project_insert($node) |
Implementation of hook_insert().
@parm $node Then node that has the information stored within, accessed given the nid
Related topics
File
- tripal_project/
tripal_project.module, line 289 - This file contains the basic functions needed for this drupal module. The drupal tripal_project module maps directly to the chado general module.
Code
function chado_project_insert($node) {
if ($node->project_id) {
$project['project_id'] = $node->project_id;
}
else {
$values = array(
'name' => $node->title,
'description' => '',
);
$project = tripal_core_chado_insert('project', $values);
}
if ($project) {
// add the description property
tripal_project_insert_property($project['project_id'], 'project_description',
$node->project_description);
// make sure the entry for this feature doesn't already exist in the chado_project table
// if it doesn't exist then we want to add it.
$project_id = chado_get_id_for_node('project', $node);
if (!$project_id) {
// next add the item to the drupal table
$sql = "INSERT INTO {chado_project} (nid, vid, project_id) " .
"VALUES (%d, %d, %d)";
db_query($sql, $node->nid, $node->vid, $project['project_id']);
}
}
else {
drupal_set_message(t('Unable to add project.', 'warning'));
watchdog('tripal_project', 'Insert feature: Unable to create project where values: %values',
array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING);
}
}