Thanks for that...

I normally just use all the data in both, if I only need info from one table, I do it like this:
# I need the members information for their profile update... #$_un carries the username they are logged in as: $sth = $dbh->selectrow_array(qq{select * from `members` where `USERNAM +E` = ? LIMIT 1}); $sth->execute($_un); my $_mbrInfo = $sth->fetchrow_hashref(); $sth->finish(); # then go build the html page and form for them to update their profil +e, prepopulating the data that is already in their
That is how I get their data, however, if I need multiple tables of information, since I store data in multiple tables, I get each of them:
$sth = $dbh->selectrow_array(qq{select * from `members` where `USERNAM +E` = ? LIMIT 1}); $sth->execute($_un); my $_mbrInfo = $sth->fetchrow_hashref(); $sth->finish(); # Got member record, now get their billing address: $sth = $dbh->prepare(qq{select * from `shippingAddresses` where `mid` += ?}); $sth->execute($_mbrInfo->{mid}); my $_addy = $sth->fetchrow_hashref(); $sth->finish();
That is how I get all the info I need, I don't usually get all the fields if I only need a few... If I only need one or two fields I do it this way:
# Get Members Id, Name, Phone, Email: my($_mbrId,$_mbrName,$_mbrPhone,$_mbrEmail) = $dbh->selectrow_array(qq +{select `mid`,`name`,`phone`,`email` from `members` where `USERNAME` += ?}, undef, $_un);
Or if I need data only out of another table, but it is based on the members id, and I only have the useranme, I do it like this:
# Get address: $sth = $dbh->selectrow_array(qq{select * from `shippingAddresses` wher +e `Id` = (select `mid` from `members` where `USERNAME` = ?)}); $sth->execute($_un); my $_addy = $sth->fetchrow_hashref(); $sth->finish();
That is how I would get just the fields I need... Since usernames are unique, I don't need to put a limit of 1 on it since there should only be one matching record.

That is how I handle those in my programming.

I am always open to new ideas though. I am currently learning Ajax to make some of the things I do much better, I am loving what I am learning! That is a GREAT language.

Thanks,
Rich

In reply to Re^4: DBI disconnect database errors by Anonymous Monk
in thread DBI disconnect database errors by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.