MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

RE: Total number of products in DB?



******    message to minivend-users from August Detlefsen <augustd@idiom.com>     ******

Here is what I wound up with:

UserTag totalprods Order table
UserTag totalprods Routine <<EOF
sub {
        my ($table) = @_;
        my $count = 0;
        open PRODUCTS, "$table";
        while (<PRODUCTS>) {
           $count++;
        }
        $count--;   #remove the entry for the header row
        return $count;
}
EOF

You call it from within the page with:

[totalprods table=/the/path/to/your/table.asc]

BY specifying which table to use in the tag, it can be used to count the number of entries in any of the DBs, or even the number of lines in any text file.

-August

PS: The question is, which of the techniques is the most efficient in terms of server load? Incrementing through every line is no problem now, but what about when there are a few thousand products in the database?

-A
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: