× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




If I need to know the number of rows ahead of time I either do a count(*)
query first or I read all the results into an array before doing any
processing. If you all the read the data into an array you can just use
the count() function to get the number of rows. Most likely net.data is
doing something similar to that if it is able to tell you how many rows
were retrieved. As far as I know, SQL does not have a facility to tell you
the number of rows a select will retrieve without actually counting them.

I suppose the third option would be to return multiple result sets. I am
not as familiar with that method, but it should work. It would still
involve two queries, but they could be done on the same request. The
performance hit would be negligible compared to two separate requests. The
first result set would include a column with the total number of rows and
the second would contain the actual data.


|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Larry Kleinman <larry@xxxxxxxxxxxxxxxxx> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|12/15/2009 09:34 AM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|[WEB400] getting number of records returned by SQL in PHP |
>--------------------------------------------------------------------------------------------------------------------------------------------------|





Hi all - net.data has a nice feature called TOTAL_ROWS which gives the
total number of rows returned by a SQL query. Is there something similar
in PHP?


Larry Kleinman
Kleinman Associates, Inc.
212-949-6469
203-255-4100
--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400..



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.