diff --git a/lib/utils/db/get.pm b/lib/utils/db/get.pm index 40dd8f3969a694575bef1a99b3c9300fea86968a..d7bf971ed74d8244480cdf3bb8c0db298e069ec1 100644 --- a/lib/utils/db/get.pm +++ b/lib/utils/db/get.pm @@ -43,6 +43,9 @@ sub get { $result = $self->_get_next($query); } + # if id was precised, we (and so the user) know there is no more results + $self->_clean($chan) if ($query->id >= 0); + return $result; } @@ -66,11 +69,18 @@ sub get_rows { sub _get_next { my ($self, $query) = @_; my $chan = $query->chan; - + my $result = $self->_sth->{$chan}->fetch(); return $result if ($result); # we come here only if there is no more data to fetch + $self->_clean($chan); + return undef; +} + +sub _clean +{ + my ($self, $chan) = @_; # we take care of the db delete $self->_sth->{$chan}; @@ -78,8 +88,6 @@ sub _get_next { # we remove the query delete $self->_queries->{$chan}; - - return undef; } sub _init {