Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 552

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>dba_open</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
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=UTF-8"></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 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.dba-nextkey.html"
ACCESSKEY="P"
>上一页</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"
>下一页</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="AEN33360"
></A
><P
>    (PHP 3 &#62;= 3.0.8, PHP 4, PHP 5)</P
>dba_open&nbsp;--&nbsp;Open database</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33363"
></A
><H2
>说明</H2
>resource <B
CLASS="methodname"
>dba_open</B
> ( string path, string mode [, string handler [, mixed ...]] )<BR
></BR
><P
>&#13;   <B
CLASS="function"
>dba_open()</B
> establishes a database instance for
   <CODE
CLASS="parameter"
>path</CODE
> with <CODE
CLASS="parameter"
>mode</CODE
> using
   <CODE
CLASS="parameter"
>handler</CODE
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33385"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>path</CODE
></DT
><DD
><P
>&#13;       Commonly a regular path in your filesystem.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>mode</CODE
></DT
><DD
><P
>&#13;       It is <TT
CLASS="literal"
>r</TT
> for read access, <TT
CLASS="literal"
>w</TT
> for
       read/write access to an already existing database, <TT
CLASS="literal"
>c</TT
>
       for read/write access and database creation if it doesn't currently exist,
       and <TT
CLASS="literal"
>n</TT
> for create, truncate and read/write access.
      </P
><P
>&#13;       Additionally you can set the database lock method with the next char. 
       Use <TT
CLASS="literal"
>l</TT
> to lock the database with a <TT
CLASS="filename"
>.lck</TT
>
       file or <TT
CLASS="literal"
>d</TT
> to lock the databasefile itself. It is 
       important that all of your applications do this consistently.
      </P
><P
>&#13;       If you want to test the access and do not want to wait for the lock 
       you can add <TT
CLASS="literal"
>t</TT
> as third character. When you are 
       absolutely sure that you do not require database locking you can do 
       so by using <TT
CLASS="literal"
>-</TT
> instead of <TT
CLASS="literal"
>l</TT
> or
       <TT
CLASS="literal"
>d</TT
>. When none of <TT
CLASS="literal"
>d</TT
>, 
       <TT
CLASS="literal"
>l</TT
> or <TT
CLASS="literal"
>-</TT
> is used, dba will lock
       on the database file as it would with <TT
CLASS="literal"
>d</TT
>.
      </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
        There can only be one writer for one database file. When you use dba on 
        a web server 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 following table:
        <DIV
CLASS="table"
><A
NAME="AEN33418"
></A
><P
><B
>表 1. DBA locking</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><COL><COL><COL><COL><COL><THEAD
><TR
><TH
>already open</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "rl"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "rlt"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "wl"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "wlt"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "rd"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "rdt"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "wd"</TH
><TH
><CODE
CLASS="parameter"
>mode</CODE
> = "wdt"</TH
></TR
></THEAD
><TBODY
><TR
><TD
>not open</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>ok</TD
></TR
><TR
><TD
><CODE
CLASS="parameter"
>mode</CODE
> = "rl"</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>wait</TD
><TD
>false</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
></TR
><TR
><TD
><CODE
CLASS="parameter"
>mode</CODE
> = "wl"</TD
><TD
>wait</TD
><TD
>false</TD
><TD
>wait</TD
><TD
>false</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
></TR
><TR
><TD
><CODE
CLASS="parameter"
>mode</CODE
> = "rd"</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>ok</TD
><TD
>ok</TD
><TD
>wait</TD
><TD
>false</TD
></TR
><TR
><TD
><CODE
CLASS="parameter"
>mode</CODE
> = "wd"</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>illegal</TD
><TD
>wait</TD
><TD
>false</TD
><TD
>wait</TD
><TD
>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 <CODE
CLASS="parameter"
>mode</CODE
> parameter.</TD
></TR
></TBODY
></TABLE
><P
></P
>
       </P
></BLOCKQUOTE
></DIV
></DD
><DT
><CODE
CLASS="parameter"
>handler</CODE
></DT
><DD
><P
>&#13;       The name of the <A
HREF="ref.dba.html#dba.requirements"
>handler</A
> which
       shall be used for accessing <CODE
CLASS="parameter"
>path</CODE
>. It is passed 
       all optional parameters given to <B
CLASS="function"
>dba_open()</B
> and 
       can act on behalf of them.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33510"
></A
><H2
>返回值</H2
><P
>&#13;   Returns a positive handle on success, or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on failure.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33514"
></A
><H2
>更新日志</H2
><P
>&#13;   <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN33517"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>版本</TH
><TH
>说明</TH
></TR
></THEAD
><TBODY
><TR
><TD
>4.3.0</TD
><TD
>&#13;        It's 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.
       </TD
></TR
><TR
><TD
>4.3.0</TD
><TD
>&#13;        Locking and the <CODE
CLASS="parameter"
>mode</CODE
> modifiers "l", "d", "-"
        and "t" were added.
        In previous PHP versions, you must use semaphores to guard against
        simultaneous database access for any database handler with the exception 
        of GDBM. See <A
HREF="ref.sem.html"
>System V semaphore support</A
>.
       </TD
></TR
><TR
><TD
>before 4.3.5</TD
><TD
>&#13;        open mode 'c' is broken for several internal handlers and truncates
        the database instead of appending data to an existent database. 
        Also dbm and ndbm fail on mode 'c' in typical configurations (this 
        cannot be fixed).
       </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33535"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.dba-popen.html"
><B
CLASS="function"
>dba_popen()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.dba-close.html"
><B
CLASS="function"
>dba_close()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </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"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.dba-optimize.html"
ACCESSKEY="N"
>下一页</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"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>dba_optimize</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>