Bug #2688: OCIFetchInto only returns OCI_NUM when called from inside a function.
| From: | tommy at webontap dot com | Date: | Mon, 08 Nov 1999 21:01:36 +0000 |
| Subject: | Bug #2688: OCIFetchInto only returns OCI_NUM when called from inside a function. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12230@lists.php.net to get a copy of this message | ||
From: tommy@webontap.com
Operating system: NT4
PHP version: 3.0.12
PHP Bug Type: Oracle related
Bug description: OCIFetchInto only returns OCI_NUM when called from inside a function.
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.