Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Populating an array via a DBI call - simplified

by Your Mother (Archbishop)
on Mar 29, 2017 at 18:07 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found