Fixed network components when search in db engine Oracle

This commit is contained in:
m-lopez-f 2015-09-02 10:58:22 +02:00
parent ec9a52337d
commit 28e1f0a7c0
2 changed files with 39 additions and 20 deletions

View File

@ -516,10 +516,10 @@ $filter = array ();
if ($search_id_group)
$filter['id_group'] = $search_id_group;
if ($search_string != '')
$filter[] = '(name LIKE "%' . $search_string . '%" ' .
'OR description LIKE "%'. $search_string . '%" ' .
'OR tcp_send LIKE "%' . $search_string . '%" ' .
'OR tcp_rcv LIKE "%' . $search_string . '%")';
$filter[] = '(name LIKE ' . "'%" . $search_string . "%'" .
'OR description LIKE ' . "'%". $search_string . "%'" .
'OR tcp_send LIKE ' . "'%" . $search_string . "%'" .
'OR tcp_rcv LIKE ' . "'%" . $search_string . "%'" . ')';
$total_components = network_components_get_network_components (false, $filter, 'COUNT(*) AS total');
$total_components = $total_components[0]['total'];

View File

@ -123,31 +123,50 @@ function network_components_get_network_components ($id_module, $filter = false,
$filter = array ();
if (! empty ($id_module))
$filter['id_modulo'] = (int) $id_module;
if (isset($filter['offset'])) {
$offset = $filter['offset'];
unset($filter['offset']);
}
if (isset($filter['limit'])) {
$limit = $filter['limit'];
unset($filter['limit']);
}
$sql = @db_get_all_rows_filter ('tnetwork_component', $filter, $fields, 'AND', false, true);
switch ($config["dbtype"]) {
case "mysql":
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit ";
}
$sql = sprintf("%s %s", $sql, $limit_sql);
$components = db_get_all_rows_sql($sql);
break;
case "postgresql":
$components = db_get_all_rows_filter ('tnetwork_component',
$filter, $fields);
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " OFFSET $offset LIMIT $limit ";
}
$sql = sprintf("%s %s", $sql, $limit_sql);
$components = db_get_all_rows_sql($sql);
break;
case "oracle":
if (count ($fields) > 1) {
$fields = implode(',',$fields);
}
if (isset($filter['offset'])) {
$components = oracle_recode_query ('SELECT ' . $fields . ' FROM tnetwork_component', $filter, 'AND', false);
if ($components != false) {
for ($i=0; $i < count($components); $i++) {
unset($components[$i]['rnum']);
}
}
}
else {
$components = db_get_all_rows_filter ('tnetwork_component',
$filter, $fields);
$set = array();
if (isset($offset) && isset($limit)) {
$set['limit'] = $limit;
$set['offset'] = $offset;
}
$components = oracle_recode_query ($sql, $set, 'AND', false);
break;
}
if ($components === false)
return array ();