Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: How to read multiple tables into arrays

by dragonchild (Archbishop)
on Nov 10, 2008 at 22:58 UTC ( #722737=note: print w/replies, xml ) Need Help??

in reply to How to read multiple tables into arrays

Take a look at an ORM, such as DBIx::Class.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: How to read multiple tables into arrays

Replies are listed 'Best First'.
Re^2: How to read multiple tables into arrays
by pinkgladiator (Initiate) on Nov 11, 2008 at 01:56 UTC
    So this is the final code I've got, but it doesn't read into college_id as it should be. Thanks! my (@colleges) = ();
    while (my @ary = $mysth->fetchrow_array()){
    push(@colleges, @ary); # @ary is a reference
    $i = 0;
    # print "colleges: ", @{colleges->$i},"\n";
    print "college id: ", $college_id, "\n";
    $myQuery = "select d.departmentName from Colleges c join Departments d on c.college_id=d.college_id where c.college_id='$college_id'";
    $deptsth = &exeQuery($mydbh, $myQuery);
    while (my @ary = $deptsth->fetchrow_array()){
    push(@departments, @ary); # @ary is a reference
    print "departments: ", @{departments->$j}, "\n";
      • You left out the initial query that was used to create "$mysth", so we don't really know what is being pushed onto "@colleges"

      • You still haven't learned about using <code> tags; this is getting in the way, and it's getting tiresome.

      • You call a function named "exeQuery", but you give us no clue what this is, or what it does (if anything) besides "prepare" and "execute".

      • You haven't told us what else you plan to do besides fetch stuff from the database and print things to show that the queries are working; the nature of the "real" task will have an impact on how you set up the query and how you handle the data returned by the query.

      Start using <code> tags (edit the posts you've already made to include these tags), tell us more about what you are really trying to accomplish (beyond just getting stuff out of a set of tables), and try to show some evidence that you are able to learn from the advice you are getting (so we know that we aren't wasting our time trying to help you).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://722737]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2018-07-21 06:23 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (444 votes). Check out past polls.