Steve
You may want to think of this from a DB perspective.
Is there a unique key associated with each of these lookups that could prevent
duplicate rows being returned? If you are looking up info for a particular person, I
would assume you would only want 1 returned and you would want a key within the table
to ensure this uniqueness.
HPH
-Jason
>
> From: "Steve Bertrand" <[EMAIL PROTECTED]>
> Date: 2004/10/05 Tue PM 05:14:41 GMT
> To: [EMAIL PROTECTED]
> Subject: DBI hashref with multiple db rows
>
> I have created a module, and inside one of the Package methods, I have
> the following code:
>
> $href = $getPlanInfo->fetchrow_hashref();
> foreach my $key (keys %$href) {
> print "$key : $href->{$key}\n";
> $name = $key;
> $self->{$name} = $href->{$key};
> }
>
> Now, in the main program that calls this method, I have the following:
>
> my ($user) = new Accounting::EagleUser();
> $user->getPlanInfo("steveb");
> print "$user->{'plan'} $user->{'username'}\n";
>
>
> What is happening, is that getPlanInfo() takes a single param, (a
> username). It then performs a fetchrow_hashref, creating the keys for
> the user object with the table field names from the db, and the values
> are the actual data from the table row.
>
> However, my problem is that some users have more than one row. I have
> tried for days, playing, reading, etc and you guys(gals) feel like my
> last hope. I can't figure out a way to give the user object multiple
> values for a single key. The output when print only shows the fetched
> row that it got first, and it appears the second is never looked at.
>
> I was thinking that if I implemented something like $self->{$key$i},
> where $i could be an incremented integer, I'd have what I was looking
> for, but how do I iterate through the DB to the next row using
> fetchrow_hashref to do this?
>
> I really appreciate any insight at all that will help clarify this for
> me, or at least put me back on a path I feel I have wandered waaay off
> of.
>
> Tks!
>
> Steve
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>