Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2563

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Open database</title>

 </head>
 <body><div class="manualnavbar" 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" id="refsect1-function.dba-open-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>dba_open</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$handler</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>dba_open()</strong></span> establishes a database instance for
   <em><code class="parameter">path</code></em> with <em><code class="parameter">mode</code></em> using
   <em><code class="parameter">handler</code></em>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dba-open-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">path</code></em></span>
     <dd>

      <p class="para">
       Commonly a regular path in your filesystem.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">mode</code></em></span>
     <dd>

      <p class="para">
       It is <em>r</em> for read access, <em>w</em> for
       read/write access to an already existing database, <em>c</em>
       for read/write access and database creation if it doesn&#039;t currently exist,
       and <em>n</em> for create, truncate and read/write access.
       The database is created in BTree mode, other modes (like Hash or Queue)
       are not supported.
      </p>
      <p class="para">
       Additionally you can set the database lock method with the next char. 
       Use <em>l</em> to lock the database with a <var class="filename">.lck</var>
       file or <em>d</em> 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 <em>t</em> as third character. When you are 
       absolutely sure that you do not require database locking you can do 
       so by using <em>-</em> instead of <em>l</em> or
       <em>d</em>. When none of <em>d</em>, 
       <em>l</em> or <em>-</em> is used, dba will lock
       on the database file as it would with <em>d</em>.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        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 class="doctable table">
         <caption><strong>DBA locking</strong></caption>
         
          <thead>
           <tr>
            <th>already open</th>
            <th><em><code class="parameter">mode</code></em> = &quot;rl&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;rlt&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;wl&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;wlt&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;rd&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;rdt&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;wd&quot;</th>
            <th><em><code class="parameter">mode</code></em> = &quot;wdt&quot;</th>
           </tr>

          </thead>

          <tbody class="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><em><code class="parameter">mode</code></em> = &quot;rl&quot;</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><em><code class="parameter">mode</code></em> = &quot;wl&quot;</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><em><code class="parameter">mode</code></em> = &quot;rd&quot;</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><em><code class="parameter">mode</code></em> = &quot;wd&quot;</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>

        <ul class="simplelist">
         <li class="member">ok: the second call will be successfull.</li>
         <li class="member">wait: the second call waits until  <span class="function"><a href="function.dba-close.html" class="function">dba_close()</a></span> is called for the first.</li>
         <li class="member">false: the second call returns false.</li>
         <li class="member">illegal: you must not mix <em>&quot;l&quot;</em> and <em>&quot;d&quot;</em> modifiers for <em><code class="parameter">mode</code></em> parameter.</li>
        </ul>
       </p>
      </p></blockquote>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">handler</code></em></span>
     <dd>

      <p class="para">
       The name of the <a href="dba.requirements.html" class="link">handler</a> which
       shall be used for accessing <em><code class="parameter">path</code></em>. It is passed 
       all optional parameters given to  <span class="function"><strong>dba_open()</strong></span> and 
       can act on behalf of them.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dba-open-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a positive handle on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.dba-open-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.0</td>
       <td>
        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>
       <td>4.3.0</td>
       <td>
        Locking and the <em><code class="parameter">mode</code></em> modifiers <em>&quot;l&quot;</em>, <em>&quot;d&quot;</em>, <em>&quot;-&quot;</em>
        and <em>&quot;t&quot;</em> 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>
       <td>4.3.5</td>
       <td>
        The open mode <em>&quot;c&quot;</em> was broken for several internal handlers and truncated
        the database instead of appending data to an existent database. 
        Also <em>dbm</em> and <em>ndbm</em> failed on mode <em>&quot;c&quot;</em> in typical configurations (this 
        cannot be fixed).
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.dba-open-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.dba-popen.html" class="function" rel="rdfs-seeAlso">dba_popen()</a> - Open database persistently</span></li>
    <li class="member"> <span class="function"><a href="function.dba-close.html" class="function" rel="rdfs-seeAlso">dba_close()</a> - Close a DBA database</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" 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>