Solved

How to find recordset count from .mdb database

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress French and English Site 6 78
Need to remove %20 from url in get 17 36
PHP alternative to file_get_contents('php://input') 4 72
PHP 5.6 and 7.x 4 23
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 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