To help understand the structures returned by the various DBI functions
I use Data::Dumper.  It helps visualize the data structure.

In your case:

use Data::Dumper;

print Dumper(getAddress($clientID);

Data::Dumper is great for debugging.

HTH

On Wed, 2003-07-23 at 19:35, Michael A Chase wrote:
> On Wed, 23 Jul 2003 01:23:11 -0800 (AKDT) John Brahy <[EMAIL PROTECTED]> wrote:
> 
> > I'm going nuts with the references here.... can anyone give me
> > a sanity check? How do I get the data out of the address array?
> > all I get is:
> > Home Phone:   ARRAY(0x83a0f88)
> > 
> > my @address   = @{ getAddress($clientID)};
> > my $homePhone = $address[0] || "n/a";
> 
> This returns an array reference for the contents of row0, the first
> row.
> 
> > sub getAddress {
> >   my ($clientID) = @_;
> >   use PfTV::Auth;
> >   my $auth = new PfTV::Auth;
> >   my $dbh = DBI->connect($auth->dsn,$auth->username,$auth->password) ||
> > die "COULDN'T CONNECT";
> >   my $sql = "select AddressID, ClientID, StatusID, Street, City, State,
> > ZipCode, HomePhone, CellPhone, Pager, Fax, WorkPhone from  Addresses
> > WHERE ClientID = $clientID";
> >   my $sth = $dbh->prepare($sql);
> >   $sth->execute;
> >   return $sth->fetchall_arrayref;
> > }
> 
> What's returned by getAddress() is an array of arrays
> [[row0],[row1],[row2],...]:
> 
>    my $addresses = getAddress( $clientID );
>    my ( $row, $AddressID, $CliendID, $StatusID, $Street, $City,
>         $State, $ZipCOde, $HomePage, $CellPhone, $Pager, $Fax,
>         $WorkPhone );
>    foreach $row ( @$addresses ) {
>       ( $AddressID, $CliendID, $StatusID, $Street, $City,
>         $State, $ZipCOde, $HomePage, $CellPhone, $Pager, $Fax,
>         $WorkPhone ) = @$row;
>       # Do something with the row's values.
>    }
-- 
Keith Jackson <[EMAIL PROTECTED]>

Reply via email to