Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 1903

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>OCINLogon</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Oracle 8 functions"
HREF="ref.oci8.html"><LINK
REL="PREVIOUS"
TITLE="OCINewDescriptor"
HREF="function.ocinewdescriptor.html"><LINK
REL="NEXT"
TITLE="OCINumCols"
HREF="function.ocinumcols.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.ocinewdescriptor.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ocinumcols.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ocinlogon"
></A
>OCINLogon</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN67401"
></A
><P
>    (PHP 3&#62;= 3.0.8, PHP 4 )</P
>OCINLogon&nbsp;--&nbsp;Establishes a new connection to Oracle</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN67404"
></A
><H2
>Description</H2
>int <B
CLASS="methodname"
>OCINLogon</B
> ( string username, string password [, string db])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>OCINLogon()</B
> creates a new connection to an
     Oracle 8 database and logs on.  The optional third parameter can
     either contain the name of the local Oracle instance or the name
     of the entry in tnsnames.ora to which you want to connect.  If
     the optional third parameter is not specified, PHP uses the
     environment variables ORACLE_SID (Oracle instance) or TWO_TASK
     (tnsnames.ora) to determine which database to connect to.
    </P
><P
>&#13;     <B
CLASS="function"
>OCINLogon()</B
> forces a new connection.  This
     should be used if you need to isolate a set of transactions.  By
     default, connections are shared at the page level if using
     <A
HREF="function.ocilogon.html"
><B
CLASS="function"
>OCILogon()</B
></A
> or at the web server process level
     if using <A
HREF="function.ociplogon.html"
><B
CLASS="function"
>OCIPLogon()</B
></A
>.  If you have multiple
     connections open using <B
CLASS="function"
>OCINLogon()</B
>, all
     commits and rollbacks apply to the specified connection only.
    </P
><P
>&#13;     This example demonstrates how the connections are separated.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN67426"
></A
><P
><B
>Example 1. OCINLogon</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>&#60;?php
print "&#60;HTML&#62;&#60;PRE&#62;";
$db = "";

$c1 = ocilogon("scott","tiger",$db);
$c2 = ocinlogon("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." committed\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." &#60;".ociresult($stmt,"TEST")."&#62;\n\n";
  echo $conn."----done\n\n";
}

create_table($c1);
insert_data($c1);

select_data($c1);   
select_data($c2);   

rollback($c1);      

select_data($c1);   
select_data($c2);   

insert_data($c2);   
commit($c2);        

select_data($c1);   

delete_data($c1);   
select_data($c1);   
select_data($c2);   
commit($c1);        

select_data($c1);
select_data($c2);

drop_table($c1);
print "&#60;/PRE&#62;&#60;/HTML&#62;";
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.ocilogon.html"
><B
CLASS="function"
>OCILogon()</B
></A
> and
     <A
HREF="function.ociplogon.html"
><B
CLASS="function"
>OCIPLogon()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.ocinewdescriptor.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ocinumcols.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>OCINewDescriptor</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.oci8.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>OCINumCols</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>