I didn't see a db2_ function that returns the number of rows from a select statement. You can look at the db2_ functions to see if I missed something:

http://us3.php.net/manual/en/ref.ibm-db2.php

If you were using a MySQL database, PHP has a function to get the number of rows from a SELECT statement. It's called mysql_num_rows.

Maybe someone will create a similar function for DB2. But I don't think it exists yet.

Kelly

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Larry Kleinman
Sent: Tuesday, December 15, 2009 9:53 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] getting number of records returned by SQL in PHP

Unless I do a GROUP BY (which I do not want to do), I don't think that I
can use the SELECT COUNT(*) and also get the actual fields returned in a
single SQL query, can I? That would mean that I would have to run the
query twice, once to get the data and once to get the count. Not a great
thing to do from a performance point of view


Larry Kleinman
Kleinman Associates, Inc.
212-949-6469
203-255-4100



Kelly Cookson <KCookson@xxxxxxxxxxxx>
Sent by: web400-bounces@xxxxxxxxxxxx
12/15/2009 09:39 AM
Please respond to
Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>


To
Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>
cc

Subject
Re: [WEB400] getting number of records returned by SQL in PHP






If you're using the db2_ functions, you can use db2_num_rows to get the
number of rows deleted, inserted, or updated by an SQL statement.

Use SELECT COUNT(*) to get the number of rows returned by a select
statement.

See the PHP manual for more info and examples:
http://www.php.net/manual/en/function.db2-num-rows.php

Kelly


-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Larry Kleinman
Sent: Tuesday, December 15, 2009 8:32 AM
To: Web Enabling the AS400 / iSeries
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

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.