ociLogOff
<<<
ociLogon OCINewCollection
>>>

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.38 ociLogon()Etablit une connexion à un serveur Oracle

[ Exemples avec ocilogon ]   PHP 3>= 3.0.4, PHP 4

resource  ocilogon ( string   username , string   password , string   db )

ocilogon retourne un identifiant de connexion, nécessaire à la plupart des fonctions oci. Si l'option ORACLE_SID n'est pas précisée, PHP utilisera la variable d'environnement ORACLE_SID pour déterminer le serveur de connexion.

Les connexions sont partagées, à l'intérieur d'une même page avec ocilogon . Cela signifie que COMMIT et ROLLBACK s'appliquent à toutes les transactions commencées à l'intérieur d'une même page, même si vous avez créé de multiples connexions.

Cet exemple montre comment les connexions sont partagées :
ociLogon

<?php
print "<HTML><PRE>";
$db = "";
$c1 = ocilogon("scott","tiger",$db);
$c2 = ocilogon("scott","tiger",$db);
function
create_table($conn)
{
$stmt = ociparse($conn,"create table scott.hallo (test
varchar2(64))"
);
  
ociexecute($stmt);
  echo
$conn." created table\n\n";
}
function
drop_table($conn)
{
$stmt = ociparse($conn,"drop table scott.hallo");
  
ociexecute($stmt);
  echo
$conn." dropped table\n\n";
}
function
insert_data($conn)
{
$stmt = ociparse($conn,"insert into scott.hallo values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
  
ociexecute($stmt,oci_DEFAULT);
  echo
$conn." inserted hallo\n\n";
}
function
delete_data($conn)
{
$stmt = ociparse($conn,"delete from scott.hallo");
  
ociexecute($stmt,oci_DEFAULT);
  echo
$conn." deleted hallo\n\n";
}
function
commit($conn)
{
ocicommit($conn);
  echo
$conn." commited\n\n";
}
function
rollback($conn)
{
ocirollback($conn);
  echo
$conn." rollback\n\n";
}
function
select_data($conn)
{
$stmt = ociparse($conn,"select * from scott.hallo");
  
ociexecute($stmt,oci_DEFAULT);
  echo
$conn."----selecting\n\n";
  while (
ocifetch($stmt))
    echo
$conn." <".ociresult($stmt,"TEST").">\n\n";
  echo
$conn."----done\n\n";
}
create_table($c1);
insert_data($c1);   // Insertion d'une ligne avec c1
insert_data($c2);   // Insertion d'une ligne avec c2
select_data($c1);   // Les résultats des deux insertions sont retournés
select_data($c2);
rollback($c1);      // Annulation avec c1
select_data($c1);   // Les résultats des deux insertions sont annulés
select_data($c2);
insert_data($c2);   // Insertion d'une ligne avec c2
commit($c2);        // Validation avec using c2
select_data($c1);   // Le résultat de c2 est retourné
delete_data($c1);   // Effacement de toutes les lignes avec c1
select_data($c1);   // Aucune ligne n'est retournée
select_data($c2);   // Aucune ligne n'est retournée
commit($c1);        // Validation avec c1
select_data($c1);   // Aucune ligne n'est retournée
select_data($c2);   // Aucune ligne n'est retournée
drop_table($c1);
print
"</PRE></HTML>";
?>

Voir aussi ociplogon et ocinlogon .

<< ociLogon >>
ociLogOff Oracle 8 OCINewCollection