
starcastle
New User
Aug 25, 2008, 5:28 PM
Post #1 of 2
(2173 views)
|
|
Loading MySql records into an array
|
Can't Post
|
|
I am having trouble making this work. I have just recently started attempting using SQL in my Perl programming and it shows I am trying to load a selected set of records from MySQL into an array. Each record has 12 fields so what I am expecting to happen is to have an array with a certain number of rows (say 10) and 12 columns. The code I use is: @sql_timedevents = (); $sql_timedevents_handle = $sql_handle->prepare('SELECT * FROM events_list where xtype="timed"'); $sql_timedevents_handle->execute(); while (my @ary = $sql_timedevents_handle->fetchrow_array()) { print_log @ary; push(@sql_timedevents,[@ary]); } $sql_timedevents_handle->finish(); This gives me the 10 rows but when I try to printout the array I have references to the columns and not the values. If I take away the [] around the @ary I get 120 rows. What I need to accomplish is to be able, later in the code, to loop through the array and use the various field data stored in it. This is probably real simple but I can see it, would appreciate any insights! Thanks, Peter
|