⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.dba-open.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Open database</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dba-nextkey.html">dba_nextkey</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dba-optimize.html">dba_optimize</a></div> <div class="up"><a href="ref.dba.html">DBA Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.dba-open" class="refentry"> <div class="refnamediv">  <h1 class="refname">dba_open</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">dba_open</span> &mdash; <span class="dc-title">Open database</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>dba_open</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$path</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$mode</tt></span>   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$handler</tt></span>   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$...</tt></span>  ]] )</div>  <p class="para rdfs-comment">   <b>dba_open()</b> establishes a database instance for   <i><tt class="parameter">path</tt></i> with <i><tt class="parameter">mode</tt></i> using   <i><tt class="parameter">handler</tt></i>.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">path</tt></i></span>     <dd>      <p class="para">       Commonly a regular path in your filesystem.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">mode</tt></i></span>     <dd>      <p class="para">       It is <i>r</i> for read access, <i>w</i> for       read/write access to an already existing database, <i>c</i>       for read/write access and database creation if it doesn&#039;t currently exist,       and <i>n</i> for create, truncate and read/write access.      </p>      <p class="para">       Additionally you can set the database lock method with the next char.        Use <i>l</i> to lock the database with a <var class="filename">.lck</var>       file or <i>d</i> to lock the databasefile itself. It is        important that all of your applications do this consistently.      </p>      <p class="para">       If you want to test the access and do not want to wait for the lock        you can add <i>t</i> as third character. When you are        absolutely sure that you do not require database locking you can do        so by using <i>-</i> instead of <i>l</i> or       <i>d</i>. When none of <i>d</i>,        <i>l</i> or <i>-</i> is used, dba will lock       on the database file as it would with <i>d</i>.      </p>      <blockquote><p><b class="note">Note</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:        <table border="5">         <caption><b>DBA locking</b></caption>         <colgroup>          <thead valign="middle">           <tr valign="middle">            <th colspan="1">already open</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;rl&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;rlt&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;wl&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;wlt&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;rd&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;rdt&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;wd&quot;</th>            <th colspan="1"><i><tt class="parameter">mode</tt></i> = &quot;wdt&quot;</th>           </tr>          </thead>          <tbody valign="middle" class="tbody">           <tr valign="middle">            <td colspan="1" rowspan="1" align="left">not open</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>           </tr>           <tr valign="middle">            <td colspan="1" rowspan="1" align="left"><i><tt class="parameter">mode</tt></i> = &quot;rl&quot;</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>           </tr>           <tr valign="middle">            <td colspan="1" rowspan="1" align="left"><i><tt class="parameter">mode</tt></i> = &quot;wl&quot;</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>           </tr>           <tr valign="middle">            <td colspan="1" rowspan="1" align="left"><i><tt class="parameter">mode</tt></i> = &quot;rd&quot;</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">ok</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>           </tr>           <tr valign="middle">            <td colspan="1" rowspan="1" align="left"><i><tt class="parameter">mode</tt></i> = &quot;wd&quot;</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">illegal</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>            <td colspan="1" rowspan="1" align="left">wait</td>            <td colspan="1" rowspan="1" align="left">false</td>           </tr>          </tbody>         </colgroup>        </table>        <ul class="simplelist">         <li class="member">ok: the second call will be successfull.</li>         <li class="member">wait: the second call waits until <a href="function.dba-close.html" class="function">dba_close()</a> is called for the first.</li>         <li class="member">false: the second call returns false.</li>         <li class="member">illegal: you must not mix &quot;l&quot; and &quot;d&quot; modifiers for <i><tt class="parameter">mode</tt></i> parameter.</li>        </ul>       <br />      </p></blockquote>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">handler</tt></i></span>     <dd>      <p class="para">       The name of the <a href="dba.setup.html#dba.requirements" class="link">handler</a> which       shall be used for accessing <i><tt class="parameter">path</tt></i>. It is passed        all optional parameters given to <b>dba_open()</b> and        can act on behalf of them.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns a positive handle on success, or <b><tt>FALSE</tt></b> on failure.  </p> </div> <div class="refsect1 changelog">  <h3 class="title">ChangeLog</h3>  <p class="para">   <table class="informaltable">    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Version</th>       <th colspan="1">Description</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">4.3.0</td>       <td colspan="1" rowspan="1" align="left">        It&#039;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 valign="middle">       <td colspan="1" rowspan="1" align="left">4.3.0</td>       <td colspan="1" rowspan="1" align="left">        Locking and the <i><tt class="parameter">mode</tt></i> modifiers &quot;l&quot;, &quot;d&quot;, &quot;-&quot;        and &quot;t&quot; 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="book.sem.html" class="link">System V semaphore support</a>.       </td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">before 4.3.5</td>       <td colspan="1" rowspan="1" align="left">        open mode &#039;c&#039; 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 &#039;c&#039; in typical configurations (this         cannot be fixed).       </td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.dba-popen.html" class="function" rel="rdfs-seeAlso">dba_popen()</a></li>    <li class="member"><a href="function.dba-close.html" class="function" rel="rdfs-seeAlso">dba_close()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dba-nextkey.html">dba_nextkey</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dba-optimize.html">dba_optimize</a></div> <div class="up"><a href="ref.dba.html">DBA Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -