Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 1196

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>OCINLogon</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Oracle 8 functions"
HREF="ref.oci8.html"><LINK
REL="PREVIOUS"
TITLE="OCIPLogon"
HREF="function.ociplogon.html"><LINK
REL="NEXT"
TITLE="OCILogOff"
HREF="function.ocilogoff.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><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.ociplogon.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ocilogoff.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ocinlogon"
>OCINLogon</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN20652"
></A
>OCINLogon -- Connect to an Oracle database and log on using a new connection. 
    Returns a new session.</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN20655"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><P
></P
><CODE
CLASS="FUNCDEF"
>int OCINLogon</CODE
>(string username, string password, string [<SPAN
CLASS="optional"
>db</SPAN
>]);<P
></P
></DIV
><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
     <B
CLASS="function"
>OCILogon()</B
> or at the web server process level
     if using <B
CLASS="function"
>OCIPLogon()</B
>.  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"
><P
><B
>Example 1. OCINLogon</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php
  3&nbsp;print "&#60;HTML&#62;&#60;PRE&#62;";
  4&nbsp;$db = "";
  5&nbsp;
  6&nbsp;$c1 = ocilogon("scott","tiger",$db);
  7&nbsp;$c2 = ocinlogon("scott","tiger",$db);
  8&nbsp;
  9&nbsp;function create_table($conn)
 10&nbsp;{ $stmt = ociparse($conn,"create table scott.hallo (test
 11&nbsp;varchar2(64))");
 12&nbsp;  ociexecute($stmt);
 13&nbsp;  echo $conn." created table\n\n";
 14&nbsp;}
 15&nbsp;
 16&nbsp;function drop_table($conn)
 17&nbsp;{ $stmt = ociparse($conn,"drop table scott.hallo");
 18&nbsp;  ociexecute($stmt);
 19&nbsp;  echo $conn." dropped table\n\n";
 20&nbsp;}
 21&nbsp;
 22&nbsp;function insert_data($conn)
 23&nbsp;{ $stmt = ociparse($conn,"insert into scott.hallo values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
 24&nbsp;  ociexecute($stmt,OCI_DEFAULT);
 25&nbsp;  echo $conn." inserted hallo\n\n";
 26&nbsp;}
 27&nbsp;
 28&nbsp;function delete_data($conn)
 29&nbsp;{ $stmt = ociparse($conn,"delete from scott.hallo");
 30&nbsp;  ociexecute($stmt,OCI_DEFAULT);
 31&nbsp;  echo $conn." deleted hallo\n\n";
 32&nbsp;}
 33&nbsp;
 34&nbsp;function commit($conn)
 35&nbsp;{ ocicommit($conn);
 36&nbsp;  echo $conn." commited\n\n";
 37&nbsp;}
 38&nbsp;
 39&nbsp;function rollback($conn)
 40&nbsp;{ ocirollback($conn);
 41&nbsp;  echo $conn." rollback\n\n";
 42&nbsp;}
 43&nbsp;
 44&nbsp;function select_data($conn)
 45&nbsp;{ $stmt = ociparse($conn,"select * from scott.hallo");
 46&nbsp;  ociexecute($stmt,OCI_DEFAULT);
 47&nbsp;  echo $conn."----selecting\n\n";
 48&nbsp;  while (ocifetch($stmt))
 49&nbsp;    echo $conn." &#60;".ociresult($stmt,"TEST")."&#62;\n\n";
 50&nbsp;  echo $conn."----done\n\n";
 51&nbsp;}
 52&nbsp;
 53&nbsp;create_table($c1);
 54&nbsp;insert_data($c1);
 55&nbsp;
 56&nbsp;select_data($c1);   
 57&nbsp;select_data($c2);   
 58&nbsp;
 59&nbsp;rollback($c1);      
 60&nbsp;
 61&nbsp;select_data($c1);   
 62&nbsp;select_data($c2);   
 63&nbsp;
 64&nbsp;insert_data($c2);   
 65&nbsp;commit($c2);        
 66&nbsp;
 67&nbsp;select_data($c1);   
 68&nbsp;
 69&nbsp;delete_data($c1);   
 70&nbsp;select_data($c1);   
 71&nbsp;select_data($c2);   
 72&nbsp;commit($c1);        
 73&nbsp;
 74&nbsp;select_data($c1);
 75&nbsp;select_data($c2);
 76&nbsp;
 77&nbsp;
 78&nbsp;drop_table($c1);
 79&nbsp;print "&#60;/PRE&#62;&#60;/HTML&#62;";
 80&nbsp;?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></P
><P
>&#13;     See also <B
CLASS="function"
>OCILogon()</B
> and
     <B
CLASS="function"
>OCIPLogon()</B
>.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.ociplogon.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ocilogoff.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>OCIPLogon</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.oci8.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>OCILogOff</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>