Evaluating first row fetched

Evaluating first row fetched

am 22.01.2005 14:22:11 von Jan Eden

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 =3D $dbh->prepare($query);
$sth->execute();
my ($list_opener, $list_closer);
while (my ($list_id, $list_title, $visible, $list_user_id, $position) =3D $=
sth->fetchrow_array) {
if ($visible || $mode eq 'edit') {
unless ($list_opener) {
($list_opener, $list_closer) =3D $position ? ("

    ", " >") : ("
      ", "
    ");
    print $list_opener;
    }
    # display the records as
  1. entries
    }
    }
    print $list_closer;

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

    Thanks,

    Jan
    --=20
    There are 10 kinds of people: those who understand binary, and those who d=
    on't

    --
    MySQL Perl Mailing List
    For list archives: http://lists.mysql.com/perl
    To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org

Re: Evaluating first row fetched

am 23.01.2005 14:36:44 von Jan Eden

Hi Carl,

Carl Holm wrote on 22.01.2005:

>You may want to consider handling some of the sorting logic with SQL
>and=20
>/or DDL if pssible.

Thanks. The rows come out sorted correctly, I only want to have an ordered =
or unordered list depending on the value of field "position" of the first r=
ow returned. It is rather an HTML formatting than a sorting problem.

Best,

Jan
--=20
Remember: use logout to logout.

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org