php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2688 OCIFetchInto only returns OCI_NUM when called from inside a function.
Submitted: 1999-11-08 16:01 UTC Modified: 2006-07-17 09:17 UTC
From: tommy at webontap dot com Assigned:
Status: Wont fix Package: OCI8 related
PHP Version: 3.0.12 OS: NT4
Private report: No CVE-ID: None
 [1999-11-08 16:01 UTC] tommy at webontap dot com
code below, works as expected:
/*--------------------------------------------------*/
$query = "SELECT * FROM USERS";
$conn = OCILogon("username", "passwd", "db");
$stmt = OCIParse($conn, $query);
OCIExecute($stmt);
while (OCIFetchInto($stmt, &$row, OCI_ASSOC)) {
	echo $row["LASTNAME"] . ", " . $row["FIRSTNAME"] . "<br>";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
/*--------------------------------------------------*/
HOWEVER...

THIS code below, does not:

/*--------------------------------------------------*/
function getusers() {
	$query = "SELECT * FROM USERS";
	$conn = OCILogon("username", "passwd", "db");
	$stmt = OCIParse($conn, $query);
	OCIExecute($stmt);
	while (OCIFetchInto($stmt, &$row, OCI_ASSOC)) {
		echo $row["LASTNAME"] . ", " . $row["FIRSTNAME"] . "<br>";
	}
	OCIFreeStatement($stmt);
	OCILogoff($conn);
}
/*--------------------------------------------------*/

After tearing my hair out for an hour, i tried THIS:

/*--------------------------------------------------*/
function getusers() {
	$query = "SELECT * FROM USERS";
	$conn = OCILogon("username", "passwd", "db");
	$stmt = OCIParse($conn, $query);
	OCIExecute($stmt);
	while (OCIFetchInto($stmt, &$row, OCI_ASSOC)) {
		echo $row[0] . ", " . $row[1] . "<br>";
	}
	OCIFreeStatement($stmt);
	OCILogoff($conn);
}
/*--------------------------------------------------*/

REGARDLESS of using OCI_ASSOC or OCI_NUM, the OCIFetchInto called from within the FUNCTION returned an enumerative 0-based array into $row, whereas the OCIFetchInto called in the ordinary code (using OCI_ASSOC) returned an associative array into $row.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-30 09:00 UTC] sniper@php.net
We are sorry, but we can not support PHP 3 related problems anymore.
Momentum is gathering for PHP 5, and we think supporting PHP 3 will
lead to a waste of resources which we want to put into getting PHP 5
ready. Of course PHP 4 will continue to be supported for the
forseeable future.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 18:01:28 2024 UTC