?
Solved

How to find recordset count from .mdb database

Posted on 2008-06-18
5
Medium Priority
?
560 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

762 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