|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-30 09:00 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 23:00:01 2025 UTC |
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.