[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Savannah-dev] DBI
From: |
Derek FEICHTINGER |
Subject: |
Re: [Savannah-dev] DBI |
Date: |
Fri, 30 May 2003 08:52:41 +0200 |
User-agent: |
KMail/1.4.3 |
Hi, Mathieu
I think this might be due to the @ret array not being declared or cleared at
the beginning of the sub. So, perl treats it as a global variable and the old
values persist when you push new elements in it (I didn't try it, just
guessing...).
Cheers,
Derek
On Thursday 29 May 2003 19:53, Mathieu Roy wrote:
> Does anyone know why with a function like this
>
> sub GetDB {
> my $table = $_[0];
> my $criterion;
> my $fields = "*";
> my $hop;
>
> $criterion = "WHERE ".$_[1] if $_[1];
> $fields = $_[2] if $_[2];
>
> $hop = $dbd->prepare("SELECT ".$fields." FROM ".$table." ".$criterion);
> $hop->execute;
> while (my (@line) = $hop->fetchrow_array) {
> push(@ret, join(",", map {defined $_ ? $_ : "0"} @line));
>
> }
> $hop->finish;
> $dbd->disconnect;
> return @ret;
> }
>
> The second time I run GetDB() in a script, it returns the result of
> the new request but also the result of the old - independantly of the
> fact that the two requests are different?
>
> The DBI man page, apart from being an advertisement for mSQL and
> Oracle, does not help me that much. Any good doc that I surely missed?
>
>
> Note that the mysql log tells me that the requests are just fine.
>
> 303 Connect address@hidden on savannah
> 303 Query SELECT
> user_name,email,realname,authorized_keys,gpg_key,status,unix_status FROM
> user 303 Query SELECT user_name,unix_group_name FROM
> user_group,groups,user WHERE groups.group_id=user_group.group_id AND
> user.user_id=user_group.user_id
--
Dr. Derek Feichtinger Tel: +41 22 767 26 98
LCG/SPI Group email: address@hidden
CERN http://people.web.psi.ch/feichtinger
CH-1211 Genève 23