> hopefully someone might be able to shed some light on this.
> loop through the rows
>    does the hash contain a key value as read from that row
>    if it does then place the row into an array and then add it to an
> array of rows which might already be within the hash
>    if the hash doesn't contain the key then create a key and add the
> row to an array an append it to the hash

I assume that you can already do the database lookup etc.
If you are then iterating over the rows, try the following:

h = Hash.new {|hash,key| hash[key] = []}
while(row = ...) #collect each row
	key = row[0]
	h[key] << row
end

This creates a hash where the value of a newly created entry is always an
array.
Therefore, you no longer need to check if the hash has the key or not, you
can simply append to the array based on the key.

Andrew Timberlake
andrew / andrewtimberlake.com
082 415 8283
skype: andrewtimberlake

"I have never let my schooling interfere with my education."
                                                --Mark Twain