in reply to parsing $sth-{NAMES}
You should always try to get a subselection of the fields from the table if you can (e.g. don't use SELECT *). If you know what fields you want in array @fields, then you can set up your select statement as
...then use fetchrow_array as follows...$sth->prepare( 'SELECT ' . join( ',', @fields ) . ' FROM database ETC +ETC ETC' );
%rowhash{ @fields } = $sth->fetchrow_array();
(whereby you are using an hash slice to make everything neat and tidy without too much extra work). However, be aware that even this way will probably be faster than fetchrow_hashref, but still on the slow side if you have lots of data. Note that if you MUST use SELECT *, or at least, you are trying to grab all the fields, you can query via DBI all the fields for a given table, put those into @fields, and use that for further SELECTS.
Also take a look at node Tricks with DBI, which tell you other things to avoid in this case.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: parsing $sth-{NAMES}
by fmogavero (Monk) on Mar 24, 2001 at 03:02 UTC | |
by chromatic (Archbishop) on Mar 24, 2001 at 11:33 UTC | |
by princepawn (Parson) on Mar 24, 2001 at 12:50 UTC | |
by lachoy (Parson) on Mar 24, 2001 at 23:13 UTC |