Re: LIMIT

From: Date: Sat, 01 Jul 2006 15:59:02 +0000
Subject: Re: LIMIT
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-42143@lists.php.net to get a copy of this message
chris smith wrote:
On 7/1/06, Dwight Altman <dwight@multicam.com> wrote:
Thanks, but that's an additional query. I was wondering if there may be a PHP function that can operate on the $result or perhaps $link of the single query that uses a LIMIT clause and
I'm not sure how this would be done in PHP (simply because I am not a PHP coder) but in Perl (as an example of the principle, so please keep your flames at bay for th etime being ;p) I'd do this: my $results_arrayref = $dbh->selectall_arrayref($query); my $number_of_results = @{ $results_arrayref }; print "Number of results: $number_of_results\n"; for my $record( @{ $results_arrayref } ) {
     # do what you want with each record...
} I'm sure PHP has a way to count how many is in a given result set without needing an additional query.

« previous php.db (#42143) next »