Home : General : Perl Programming :

General: Perl Programming: ArrayRef to Hash: Edit Log

Here is the list of edits for this post
ArrayRef to Hash
Hi,

I need (well don't need but would like) to use FETCHALL_ARRAYREF to select rows from mysql but I need the end result to be a hash because I need key names rather than numbers for my template parser, eg <%Foo%> not <%1%>. So I guess this is not the way to go.

Would anyone like to provide some code that will use FETCHROW_HASHREF but return the data as a hash :)

The query is.... SELECT * FROM Table ORDER BY Foo ASC LIMIT 0,25

Is it possible to use dereferencing?

If I had:

ColA, ColB, ColC

Row1, Row2, Row3

....I'm guessing the hashref would look like:

$hash = {
Row1 => { ColA, ColB, ColC },
Row2 => { ColA, ColB, ColC },
Row3 => { ColA, ColB, ColC },
};

Is that close?...that makes me think I can't use a normal hash for this.

Thanks!

Last edited by:

PaulW: Nov 20, 2001, 7:39 AM

Edit Log: