Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>dba_open</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="Database (dbm-style) abstraction layer functions"
HREF="ref.dba.html"><LINK
REL="PREVIOUS"
TITLE="dba_nextkey"
HREF="function.dba-nextkey.html"><LINK
REL="NEXT"
TITLE="dba_optimize"
HREF="function.dba-optimize.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.dba-nextkey.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.dba-optimize.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.dba-open"
></A
>dba_open</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN16133"
></A
><P
>    (PHP 3&#62;= 3.0.8, PHP 4 )</P
>dba_open&nbsp;--&nbsp;Open database</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN16136"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>dba_open</B
> ( string path, string mode, string handler [, ...])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>dba_open()</B
> establishes a database instance for
     <TT
CLASS="parameter"
><I
>path</I
></TT
> with <TT
CLASS="parameter"
><I
>mode</I
></TT
> using
     <TT
CLASS="parameter"
><I
>handler</I
></TT
>.
    </P
><P
>&#13;     <TT
CLASS="parameter"
><I
>path</I
></TT
> is commonly a regular path in your filesystem.
    </P
><P
>&#13;     <TT
CLASS="parameter"
><I
>mode</I
></TT
> is "r" for read access, "w" for read/write
     access to an already existing database, "c" for read/write access
     and database creation if it doesn't currently exist, and "n" for
     create, truncate and read/write access. Additional you can set the databse
     lock method with the next char. Use "l" to lock the database with an .lck 
     file or "d" to lock the databasefile itself. It is important that all of 
     your applications do this consistently. If you want to test the access and 
     do not want to wait for the lock you can add "t" as third character. When 
     you are absolutly sure that you do not require database locking you can do 
     so by using "-" instead of "l" or "d". When none of "d", "l" or "-" is used
     dba will lock on the database file as it would with "d".
    </P
><P
>&#13;     <TT
CLASS="parameter"
><I
>handler</I
></TT
> is the <A
HREF="ref.dba.html#dba.requirements"
>name
     of the handler</A
> which shall be
     used for accessing <TT
CLASS="parameter"
><I
>path</I
></TT
>. It is passed all optional
     parameters given to <B
CLASS="function"
>dba_open()</B
> and can act on behalf of
     them.
    </P
><P
>&#13;     <B
CLASS="function"
>dba_open()</B
> returns a positive handle or <TT
CLASS="constant"
><B
>FALSE</B
></TT
>, in
     the case the database was opened successfull or fails, respectively.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      There can only be one writer for one database file. When you use dba on 
      a webserver and more than one request requires write operations they can
      only be done one after another. Also read during write is not allowed.
      The dba extension uses locks to prevent this. See the follwoing table:
      <DIV
CLASS="table"
><A
NAME="AEN16171"
></A
><P
><B
>Table 1. DBA locking</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>already open</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rl"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rlt"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wl"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wlt"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rd"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rdt"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wd"</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wdt"</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>not open</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rl"</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wl"</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "rd"</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>ok</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="parameter"
><I
>mode</I
></TT
> = "wd"</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>illegal</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>wait</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>false</TD
></TR
></TBODY
></TABLE
></DIV
>
      <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>ok: the second call will be successfull.</TD
></TR
><TR
><TD
>wait: the second call waits until <A
HREF="function.dba-close.html"
><B
CLASS="function"
>dba_close()</B
></A
> is called for the first.</TD
></TR
><TR
><TD
>false: the second call returns false.</TD
></TR
><TR
><TD
>illegal: you must not mix "l" and "d" modifiers for <TT
CLASS="parameter"
><I
>mode</I
></TT
> parameter.</TD
></TR
></TBODY
></TABLE
><P
></P
>
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      Since PHP 4.3.0 it is possible to open database files over network connection.
      However in cases a socket connection will be used (as with http or ftp) the
      connection will be locked instead of the resource itself. This is important to
      know since in such cases locking is simply ignored on the resource and other
      solutions have to be found.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      Locking and the <TT
CLASS="parameter"
><I
>mode</I
></TT
> modifiers "l", "d", "-" and "t" were
      added in PHP 4.3.0.
      In PHP versions before PHP 4.3.0 you must use semaphores to guard against
      simultanious database access for any database handler with the exception of
      GDBM. See <A
HREF="ref.sem.html"
>System V semaphore support</A
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also:
     <A
HREF="function.dba-popen.html"
><B
CLASS="function"
>dba_popen()</B
></A
>
     <A
HREF="function.dba-close.html"
><B
CLASS="function"
>dba_close()</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.dba-nextkey.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.dba-optimize.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>dba_nextkey</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.dba.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>dba_optimize</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>