[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] How do I pull out the field-names from a query?
Quoting Mike Heins (mike@valuemedia.com):
> Quoting Rene Hertell (interchange@hertell.com):
> > > Examine the calling documentation better.
> > >
> > > ($ary, $field_hash, $name_array) = $db->query($sql);
> >
> > Hi Mike,
> >
> > I'm sorry, but I can't find that part of the documentation.. :(
> >
> > Could you please guide me in the right direction..
> >
>
> The right direction is to give me a swat upside the head. Or the person
> who mangled my embedded Perl documentation, anyway. 8-)
>
> Which could have been me, I suppose. I am sure I had it in there, but it
> got lost as so many things did during the docs changeover. 8-\
>
> There is a missing call in ictemplates.sdf:
>
> ## $ary is result array of arrays/hashes
> ## $field_hash gives pointers to field indicies in the $ary
> ## $name_array is field names for query
> ($ary, $field_hash, $name_array) = $db->query($sql);
>
> So if you make this call:
>
> my $sql = 'select sku,price,description from products';
> my ($ary, $fh, $na) = $db->query($sql);
>
> $na will be [ 'sku, price, description' ].
Correction:
$na will be [ 'sku', 'price', 'description' ].
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.513.523.7621 <mike@perusion.com>
Fast, reliable, cheap. Pick two and we'll talk. -- unknown