2009-12-08 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_db.php: add in "get_db_all_rows_filter" new parameter $returnSQL for return the string formated SQL instead the data. And add new function "get_db_all_row_by_steps_sql" that return row by row the data of query. * operation/events/export_csv.php: fixed the memory overload when try save into CSV a 10000 events or more, now use "get_db_all_row_by_steps_sql" for extract row by row the data. Fixes: 2859758 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2175 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4ac5cbd3d9
commit
a18ddccdc3
|
@ -1,3 +1,15 @@
|
|||
2009-12-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_db.php: add in "get_db_all_rows_filter" new parameter
|
||||
$returnSQL for return the string formated SQL instead the data. And add new
|
||||
function "get_db_all_row_by_steps_sql" that return row by row the data of
|
||||
query.
|
||||
|
||||
* operation/events/export_csv.php: fixed the memory overload when try save
|
||||
into CSV a 10000 events or more, now use "get_db_all_row_by_steps_sql" for
|
||||
extract row by row the data.
|
||||
Fixes: 2859758
|
||||
|
||||
2009-12-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* operation/events/events.php: fix notice undefined var message.
|
||||
|
|
|
@ -1837,10 +1837,11 @@ function get_db_all_rows_sql ($sql) {
|
|||
* @param mixed Fields of the table to retrieve. Can be an array or a coma
|
||||
* separated string. All fields are retrieved by default
|
||||
* @param string Condition of the filter (AND, OR).
|
||||
* @param bool $returnSQL Return a string with SQL instead the data, by default false.
|
||||
*
|
||||
* @return mixed Array of the row or false in case of error.
|
||||
*/
|
||||
function get_db_all_rows_filter ($table, $filter, $fields = false, $where_join = 'AND') {
|
||||
function get_db_all_rows_filter ($table, $filter, $fields = false, $where_join = 'AND', $returnSQL = false) {
|
||||
//TODO: Validate and clean fields
|
||||
if (empty ($fields)) {
|
||||
$fields = '*';
|
||||
|
@ -1860,7 +1861,27 @@ function get_db_all_rows_filter ($table, $filter, $fields = false, $where_join =
|
|||
}
|
||||
|
||||
$sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
if ($returnSQL)
|
||||
return $sql;
|
||||
else
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row by row the DB by SQL query. The first time pass the SQL query and
|
||||
* rest of times pass none for iterate in table and extract row by row, and
|
||||
* the end return false.
|
||||
*
|
||||
* @param string $sql
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function get_db_all_row_by_steps_sql($sql = null) {
|
||||
static $result;
|
||||
|
||||
if ($sql !== null)
|
||||
$result = mysql_query($sql);
|
||||
|
||||
return mysql_fetch_assoc($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,10 +71,11 @@ echo chr (13);
|
|||
|
||||
$fields = array ('id_grupo', 'id_agente', 'evento', 'estado', 'id_usuario',
|
||||
'event_type', 'criticity', 'timestamp');
|
||||
$events = get_events ($filter, $fields);
|
||||
if ($events === false)
|
||||
$events = array ();
|
||||
foreach ($events as $event) {
|
||||
|
||||
$sql = get_db_all_rows_filter ('tevento', $filter, $fields, 'AND', true);
|
||||
get_db_all_row_by_steps_sql($sql);
|
||||
|
||||
while ($event = get_db_all_row_by_steps_sql()) {
|
||||
if (! give_acl ($config["id_user"], $event["id_grupo"], "AR"))
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue