Evaluating first row fetched

Jan Eden <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <r02010400-1037-A03AE0FA6C7811D9B134000A959B4026@[192.168.2.100]>
Hi,

I have to print either an ordered or an unordered list of items, dependent of the value of a certain field of the first row returned. Since there are a lot of rows to fetch, I cannot use fetchall_arrayref/hashref.

I currently use the following code:

my $sth = $dbh->prepare($query);
$sth->execute();
my ($list_opener, $list_closer);
while (my ($list_id, $list_title, $visible, $list_user_id, $position) = $sth->fetchrow_array) {
        if ($visible || $mode eq 'edit') {
            unless ($list_opener) {
                ($list_opener, $list_closer) = $position ? ("<ol>", "</ol>") : ("<ul>", "</ul>");
                print $list_opener;
            }
            # display the records as <li> entries
        }
    }
    print $list_closer;

Is there a more elegant way to evaluate the value of field "position" of the first row outside the while loop?

Thanks,

Jan
-- 
There are 10 kinds of people:  those who understand binary, and those who don't

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.