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.
   }

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to