From f120f5b288cca508bf7a97707afbe90399c0dc9e Mon Sep 17 00:00:00 2001 From: jsatoh Date: Sat, 24 Mar 2012 12:15:18 +0000 Subject: [PATCH] 2012-03-24 Junichi Satoh * include/functions_agents.php, include/functions_config.php, include/db/postgresql.php, operation/agentes/estado_agente.php: Fixed SQL error with PostgreSQL. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5825 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/include/db/postgresql.php | 4 ++-- pandora_console/include/functions_agents.php | 10 +++++++++- pandora_console/include/functions_config.php | 2 +- pandora_console/operation/agentes/estado_agente.php | 3 +-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 688c9130f8..7df5638409 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-03-24 Junichi Satoh + + * include/functions_agents.php, include/functions_config.php, + include/db/postgresql.php, operation/agentes/estado_agente.php: Fixed + SQL error with PostgreSQL. + 2012-03-24 Junichi Satoh * include/help/ja/help_wmifield.php: Fixed wmi field help. diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index 7e241d6e28..2d3c2628d6 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -278,7 +278,7 @@ function postgresql_db_process_sql($sql, $rettype = "affected_rows", $dbconnecti */ function postgresql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') { if ($order_field != "") { - return db_get_all_rows_sql ('SELECT * FROM "'.$table.'" ORDER BY "'.$order_field . '" ' . $order); + return db_get_all_rows_sql ('SELECT * FROM "'.$table.'" ORDER BY '.$order_field . ' ' . $order); } else { return db_get_all_rows_sql ('SELECT * FROM "'.$table.'"'); @@ -789,7 +789,7 @@ function postgresql_db_get_all_fields_in_table ($table, $field = '', $condition } if ($order_field != "") - $sql .= sprintf (" ORDER BY \"%s\"", $order_field); + $sql .= sprintf (" ORDER BY %s", $order_field); return db_get_all_rows_sql ($sql); } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d793eb438b..5da04264e0 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -491,13 +491,21 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o switch ($config["dbtype"]) { case "mysql": - case "postgresql": $limit_sql = ''; if(isset($offset) && isset($limit)) { $limit_sql = " LIMIT $offset, $limit "; } $sql = sprintf("%s %s", $sql, $limit_sql); + $agents = db_get_all_rows_sql($sql); + break; + case "postgresql": + $limit_sql = ''; + if(isset($offset) && isset($limit)) { + $limit_sql = " OFFSET $offset LIMIT $limit "; + } + $sql = sprintf("%s %s", $sql, $limit_sql); + $agents = db_get_all_rows_sql($sql); break; case "oracle": diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 40b0a619c3..eb37170c13 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -677,7 +677,7 @@ function config_check (){ $now = date("U"); // First action in order to know if it's a new installation or db maintenance never have been executed - $first_action = db_get_value_filter('utimestamp', 'tsesion', array('1' => '1', 'order' => 'id_sesion ASC')); + $first_action = db_get_value_filter('utimestamp', 'tsesion', array('1' => 'true', 'order' => 'id_sesion ASC')); $fresh_installation = $now - $first_action; $resta = $now - $db_maintance; diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 560fa16d3f..005e5a47d1 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -301,12 +301,11 @@ $total_agents = 0; $agents = false; $total_agents = agents_get_agents(array ( - 'order' => 'nombre ASC', 'disabled' => 0, 'id_grupo' => $groups, 'search' => $search_sql, 'status' => $status), - array ('COUNT(*) as total')); + array ('COUNT(*) as total'), 'AR', false); $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; $agents = agents_get_agents(array (