Fixed the alert info retrieving for oracle databases

This commit is contained in:
Alejandro Gallardo Escobar 2015-06-16 17:53:30 +02:00
parent 1905c8a038
commit 3e2391a7c3

View File

@ -662,30 +662,38 @@ function alerts_get_alert_templates ($filter = false, $fields = false) {
function alerts_get_alert_template ($id_alert_template) { function alerts_get_alert_template ($id_alert_template) {
global $config; global $config;
$alert_templates = false;
$id_alert_template = safe_int ($id_alert_template, 1); $id_alert_template = safe_int ($id_alert_template, 1);
if (empty ($id_alert_template))
return false;
switch ($config['dbtype']) { if (!empty ($id_alert_template)) {
case "mysql": switch ($config['dbtype']) {
case "postgresql": case "mysql":
return db_get_row ('talert_templates', 'id', $id_alert_template); case "postgresql":
break; $alert_templates = db_get_row ('talert_templates', 'id', $id_alert_template);
case "oracle": break;
$fields_select = db_get_all_rows_sql('SELECT column_name case "oracle":
FROM user_tab_columns $sql = "SELECT column_name
WHERE table_name = \'TALERT_TEMPLATES\' FROM user_tab_columns
AND column_name NOT IN (\'TIME_FROM\',\'TIME_TO\')'); WHERE table_name = 'TALERT_TEMPLATES'
foreach ($fields_select as $field_select){ AND column_name NOT IN ('TIME_FROM','TIME_TO')";
$select_field[] = $field_select['column_name']; $fields_select = db_get_all_rows_sql($sql);
}
$select_stmt = implode(',', $select_field); $column_names = array_map(function($item) {
return db_get_row_sql("SELECT $select_stmt, return $item['column_name'];
to_char(time_from, 'hh24:mi:ss') AS time_from, }, $fields_select);
to_char(time_to, 'hh24:mi:ss') AS time_to $column_names_str = implode(',', $column_names);
FROM talert_templates");
break; $sql = "SELECT $column_names_str,
to_char(time_from, 'hh24:mi:ss') AS time_from,
to_char(time_to, 'hh24:mi:ss') AS time_to
FROM talert_templates
WHERE id = $id_alert_template";
$alert_templates = db_get_row_sql($sql);
break;
}
} }
return $alert_templates;
} }
/** /**