OCINewCollection
<<<
ociNewCursor ociNewDescriptor
>>>

6.71 Oracle 8
6 Index des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Configuration à l'exécution
Types de ressources
Constantes Prédefinies
Exemples
ociBindByName
OCICancel
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

6.71.40 ociNewCursor() Retourne un nouveau pointeur à utiliser pour lier les pointeurs de références

[ Exemples avec ocinewcursor ]   PHP 3>= 3.0.8, PHP 4

int  ocinewcursor ( resource   conn )

ocinewcursor alloue un nouveau pointeur de commande, pour la connexion conn .

Utiliser un REF CURSOR issue d'une procédure enregistrée.

<?php
// supposons que votre procédure stoquée info.output retourne un pointeur
// de curseur dans : data
$conn = ociLogon("scott","tiger");
$curs = ociNewCursor($conn);
$stmt = ociparse($conn,"begin info.output(:data); end;");
ocibindbyname($stmt,"data",&$curs,-1,oci_B_CURSOR);
ociexecute($stmt);
ociexecute($curs);
while (
ociFetchInto($curs,&$data)) {
    
var_dump($data);
}
ociFreeStatement($curs);
ociFreeCursor($stmt);
ociLogoff($conn);
?>

Utiliser un REF CURSOR issue d'une commande SELECT

<?php
print "<HTML><BODY>";
$conn = ociLogon("scott","tiger");
$count_cursor = "CURSOR(select count(empno) num_emps from emp " .
                
"where emp.deptno = dept.deptno) as EMPCNT from dept";
$stmt = ociparse($conn,"select deptno,dname,$count_cursor");
ociexecute($stmt);
print
"<TABLE BORDER=\"1\">";
print
"<TR>";
print
"<TH>DEPT NAME</TH>";
print
"<TH>DEPT #</TH>";
print
"<TH># EMPLOYEES</TH>";
print
"</TR>";
while (
ociFetchInto($stmt,&$data,oci_ASSOC)) {
    print
"<TR>";
    
$dname  = $data["DNAME"];
    
$deptno = $data["DEPTNO"];
    print
"<TD>$dname</TD>";
    print
"<TD>$deptno</TD>";
    
ociexecute($data[ "EMPCNT" ]);
    while (
ociFetchInto($data[ "EMPCNT" ],&$subdata,oci_ASSOC)) {
        
$num_emps = $subdata["NUM_EMPS"];
        print  
"<TD>$num_emps</TD>";
    }
    print
"</TR>";
}
print
"</TABLE>";
print
"</BODY></HTML>";
ociFreeStatement($stmt);
ociLogoff($conn);
?>

<< ociNewCursor >>
OCINewCollection Oracle 8 ociNewDescriptor