note 25746 deleted from function.ocifetchinto by sixd

From: Date: Wed, 20 Nov 2013 19:45:58 +0000
Subject: note 25746 deleted from function.ocifetchinto by sixd
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197577@lists.php.net to get a copy of this message
Note Submitter: xerxes at dataforce dot com dot au ---- 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

« previous php.notes (#197577) next »