Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Populating an array via a DBI call - simplified

by Your Mother (Archbishop)
on Mar 29, 2017 at 18:07 UTC ( #1186415=note: print w/replies, xml ) Need Help??


in reply to Populating an array via a DBI call - simplified

This is a great chance to bump one of the most classic nodes here: DBI recipes.

  • Comment on Re: Populating an array via a DBI call - simplified

Replies are listed 'Best First'.
Re^2: Populating an array via a DBI call - simplified
by edimusrex (Monk) on Mar 29, 2017 at 19:27 UTC

    Great thread. Seems the answer to my question is as followed ---

    my @accounts = @{$dbh->selectcol_arrayref("SELECT `UserName` FROM Acco +unt a, asscAccountAccountGroup aaag, asscRoleAccountGroup arag, Role +r WHERE a.Id = aaag.AccountId AND aaag.AccountGroupId = arag.AccountG +roupId AND arag.RoleId = r.Id AND r.Name = 'ROLE_REVIEWER'")}; print join("\n",@accounts);

    Thanks again for pointing me in the right direction

      If you don't really need the entire list of results in an array, you can just fetch one at a time like so:
      my $sth = $dbh->prepare($sql); $sth->execute(); $sth->bind_col( 1, \my $user_name ); while ( $sth->fetch() ) { print "$user_name\n"; }
Re^2: Populating an array via a DBI call - simplified
by edimusrex (Monk) on Mar 29, 2017 at 19:22 UTC
    Great! Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1186415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2021-06-22 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (102 votes). Check out past polls.

    Notices?