ocifetchinto
(PHP 4, PHP 5, PHP 7, PECL OCI8 >= 1.0.0)
ocifetchinto — Устаревший вариант функций oci_fetch_array(), oci_fetch_object(), oci_fetch_assoc() и oci_fetch_row()
Описание
Устаревший вариант функций oci_fetch_array(), oci_fetch_object(), oci_fetch_assoc() и oci_fetch_row()
Внимание
Этот псевдоним функции УСТАРЕЛ начиная с версии PHP 5.4.0. Использование этого псевдонима крайне не рекомендуется.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- Oracle OCI8
- ocibindbyname
- ocicancel
- ocicloselob
- ocicollappend
- ocicollassign
- ocicollassignelem
- ocicollgetelem
- ocicollmax
- ocicollsize
- ocicolltrim
- ocicolumnisnull
- ocicolumnname
- ocicolumnprecision
- ocicolumnscale
- ocicolumnsize
- ocicolumntype
- ocicolumntyperaw
- ocicommit
- ocidefinebyname
- ocierror
- ociexecute
- ocifetch
- ocifetchinto
- ocifetchstatement
- ocifreecollection
- ocifreecursor
- ocifreedesc
- ocifreestatement
- ociinternaldebug
- ociloadlob
- ocilogoff
- ocilogon
- ocinewcollection
- ocinewcursor
- ocinewdescriptor
- ocinlogon
- ocinumcols
- ociparse
- ociplogon
- ociresult
- ocirollback
- ocirowcount
- ocisavelob
- ocisavelobfile
- ociserverversion
- ocisetprefetch
- ocistatementtype
- ociwritelobtofile
- ociwritetemporarylob
Коментарии
When using ocifetchinto, be careful with the resulting array. If the array variable is previously populated before calling ocifetchinto, and the the ocifetchinto command returns no (0) rows, the array is not overwritten. This can make you think that you actually got rows returned when you actually didn't.
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
There might be a better way.
<?php
$conn = OCILogon('user', 'secret', 'DB');
$th = 0; // Table Header
$query = 'select * from PAYMENT';
$stid = OCIParse($conn, $query);
OCIExecute($stid);
echo "<table>\n\n";
while (OCIFetchInto($stid, $row, OCI_ASSOC)) {
if (!$th) {
$keys = (array_keys($row));
echo "\n<tr>\n";
foreach ($keys as $k) {echo "<th>" . $k . "</th>\n";}
echo "</tr>\n";
$th = 1; // Table header done !
}
echo "\n<tr>\n";
foreach ($keys as $k) {echo "<td>" . $row[$k] . "</td>\n";}
echo "</tr>\n";
$count = $count + 1;
}
echo "</table>\n\n";
echo "<h3>" . $count . " records</h3>";
OCILogoff($conn);
?>