php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16742 odbc_fetch_row fails when parameters 2 set
Submitted: 2002-04-23 01:07 UTC Modified: 2002-05-01 03:20 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: badams at ingenico dot com dot au Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.2.0 OS: win2000 sp2
Private report: No CVE-ID: None
 [2002-04-23 01:07 UTC] badams at ingenico dot com dot au
The following code works for the first sql statement however fails on the odbc_fetch_row for the second when the second parmeter is set. This works for php4.1.2 but fails on php4.2.0

ODBC connected to Access97 database, running Apache2
----------------------------------------------------
CODE
----------------------------------------------------
  $DB_TMS = odbc_connect("tms", "", "");
  
  $sql = "select * from users where name='Root' and pass='1111'";
  $res = odbc_exec($DB_TMS, $sql);
  if( odbc_fetch_row($res)) echo "Found Record <br>";
  else echo "No Record Found <br> ";    
  odbc_free_result($res);
      
  $sql = "select * from users where name='Root' and pass='1111'";
  $res = odbc_exec($DB_TMS, $sql);
  if( odbc_fetch_row($res, 1)) echo "Found Record <br>";
  else echo "No Record Found <br> ";  
  odbc_free_result($res);
      
  odbc_close_all( );

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-24 08:59 UTC] rschuler at psi dot de
ODBC communication also fail with OS: NT40 (and Apache)
 No error return!! (work with php 4.1.1)

Code:

<?php
$conn = odbc_connect($dsn, $uid, $pwd) or die( "Error DB connect" );

$sql="SELECT * FROM $dbname ORDER BY dateposted DESC";
if(($result = odbc_exec($conn, $sql))) {
	$bzm = 1;
	while(odbc_fetch_row($result, $bzm)) {
		echo odbc_result($result,"name")."<br>";
				$bzm++;
	}
}
odbc_free_result($result);
?>
 [2002-04-26 07:40 UTC] Marcus dot Karlsson at testbolaget dot se
For MyODBC towards MySQL this problem is due to incorrect cursor type. I the function odbc_exec/odbc_prepare(), the cursor is set to SQL_CURSOR_FORWARD_ONLY which makes it impossible for MyODBC to use SQLFetchExtended().

To make this function work with MyODBC, change to SQL_CURSOR_STATIC on line 1184 in php_odbc.c. To make this work with odbc_prepare() i guess line 820 has to be changed as well.

/* $Id: php_odbc.c,v 1.120.2.1 2002/04/08 22:21:30 sniper Exp $ */

Marcus Karlsson
Testbolaget AB
 [2002-04-26 10:27 UTC] kalowsky@php.net
As far as the cursor is concerned, from the MS ODBC SDK:

SQLExtendedFetch Similar to SQLFetch but returns multiple rows using an array for each column. The result set is forward-scrollable and can be made backward-scrollable if the cursor is defined to be static, not forward-only.

The code for the first two examples is correct (the php source and the sample scripts).  I'm wondering if the ODBC v3.7 (in the latests MDACs from MS) isn't mapping SQLFetchScroll to SQLExtendedFetch properly, or if it's somewhere else.
 [2002-05-01 02:29 UTC] christoph dot grottolo at gmx dot net
This bug seems to be fixed in the latest snapshots of 4.2 branch and HEAD as of 2002-05-01. At least for me it works again.

Thanks a lot

Christoph
 [2002-05-01 03:20 UTC] derick@php.net
Closing... fix will be in 4.2.1 (due in a few days).

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 20:01:29 2024 UTC