Solved

How to find recordset count from .mdb database

Posted on 2008-06-18
5
554 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now