function get_max_chado_rank
2.x tripal_core.DEPRECATED.api.inc | get_max_chado_rank($tablename, $where_options) |
3.x tripal_core.DEPRECATED.inc | get_max_chado_rank($tablename, $where_options) |
1.x other_module_api_functions.inc | get_max_chado_rank($tablename, $where_options) |
2 calls to get_max_chado_rank()
- tripal_stock_add_ONE_property_form_submit in tripal_stock/
includes/ tripal_stock-properties.inc - tripal_stock_update_property in tripal_stock/
includes/ tripal_stock-properties.inc
File
- tripal_stock/
includes/ other_module_api_functions.inc, line 29 - @todo Add file header description
Code
function get_max_chado_rank($tablename, $where_options) {
$where = array();
//generate the where clause from supplied options
// the key is the column name
foreach ($where_options as $key => $val_array) {
if (preg_match('/INT/', $val_array['type'])) {
$where[] = $key . "=" . $val_array['value'];
}
else {
if ($val_array['exact']) {
$operator = '=';
}
else {
$operator = '~';
}
$where[] = $key . $operator . "'" . $val_array['value'] . "'";
}
}
$result = db_fetch_object(chado_query(
"SELECT max(rank) as max_rank, count(rank) as count FROM {%s} WHERE %s",
$tablename,
implode(' AND ', $where)
));
//drupal_set_message("Max Rank Query=SELECT max(rank) as max_rank, count(rank) as count FROM ".$tablename." WHERE ".implode(' AND ',$where));
if ($result->count > 0) {
return $result->max_rank;
}
else {
return -1;
}
}