note 25746 added to function.ocifetchinto

From: Date: Fri, 04 Oct 2002 02:37:15 +0000
Subject: note 25746 added to function.ocifetchinto
Groups: php.notes 
Request: Send a blank email to php-notes+get-37651@lists.php.net to get a copy of this message
Hi all.... Following an eariler message about having similar functionality to "mysql_fetch_object", here is a snip of code i frequently use to return an array of all rows from a query....each element of the array is an object, where the properties for the object are the columns selected from the query. Note that this function reqs that you pass in a connection handler.... It can be modified to return just a single row, quite easily. function executeSQL($SQL, $oConn) { $cur = OCIParse($oConn, $SQL); if (OCIExecute($cur, OCI_DEFAULT)) { $iCounter = 0; $aGeneric = Array(); $TempClass = new stdClass (); while(OCIFetchInto($cur, $res, OCI_RETURN_NULLS + OCI_ASSOC)) { foreach ($res as $sKey => $sVal) { $TempClass->{$sKey} = $sVal; } $aGeneric[$iCounter] = $TempClass; $iCounter++; } } else { return (false); } return ($aGeneric); } hth! -Xerxes -- http://www.php.net/manual/en/function.ocifetchinto.php http://master.php.net/manage/user-notes.php?action=edit+25746 http://master.php.net/manage/user-notes.php?action=delete+25746 http://master.php.net/manage/user-notes.php?action=reject+25746

« previous php.notes (#37651) next »