Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Populating an array via a DBI call - simplified

by edimusrex (Monk)
on Mar 29, 2017 at 19:27 UTC ( #1186424=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^3: Populating an array via a DBI call - simplified
by runrig (Abbot) on Mar 29, 2017 at 20:56 UTC
    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"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2019-07-23 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (27 votes). Check out past polls.

    Notices?