Solved

How to find recordset count from .mdb database

Posted on 2008-06-18
5
556 Views
Last Modified: 2008-06-20
How can I tell if any recordset or how many recorset are returned from the statement below?

$rs1 = odbc_exec($conn,$sql);
0
Comment
Question by:rrhandle8
  • 3
5 Comments
 
LVL 5

Expert Comment

by:Alex-w474
ID: 21818518
0
 

Author Comment

by:rrhandle8
ID: 21818635
$numrows = odbc_num_rows($rs1);
Always returns -1
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21819918
odbc_num_rows(), This function will return -1 on error, ....there is an error on your $rs1 .. record set .. just check it., then pass the valid rs source.,

0
 
LVL 5

Expert Comment

by:Alex-w474
ID: 21820330
So if you need to check whether records returned or not, you can use the following code:

$rs1 = odbc_exec($conn,$sql);
$isEmpty = (false == odbc_fetch_row($rs1));

Open in new window

0
 
LVL 5

Accepted Solution

by:
Alex-w474 earned 50 total points
ID: 21820333
There may be now way to detect how many records are returned except iterating through the recordset till the end or executing SQL statement with COUNT(*) function as follows:

$rs1 = odbc_exec($conn, 'select count(*) from (' . $sql . ') cnt');
if (odbc_fetch_row($rs1)) {
  $cnt = odbc_result($rs1, 1);
}

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question