<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.dba.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.dba-open.php',
    1 => 'dba_open',
    2 => '&Ouml;ffnet eine Datenbank',
  ),
  'up' => 
  array (
    0 => 'ref.dba.php',
    1 => 'DBA-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.dba-nextkey.php',
    1 => 'dba_nextkey',
  ),
  'next' => 
  array (
    0 => 'function.dba-optimize.php',
    1 => 'dba_optimize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/dba/functions/dba-open.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.dba-open" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dba_open</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">dba_open</span> &mdash; <span class="dc-title">Öffnet eine Datenbank</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.dba-open-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>dba_open</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$mode</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$handler</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$permission</code><span class="initializer"> = 0644</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$map_size</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><span class="type"><a href="class.dba-connection.php" class="type Dba\Connection">Dba\Connection</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   <span class="function"><strong>dba_open()</strong></span> stellt eine Datenbankinstanz für
   <code class="parameter">path</code> mit <code class="parameter">mode</code> her und verwendet
   dabei <code class="parameter">handler</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.dba-open-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">path</code></dt>
    <dd>
     <span class="simpara">
      Ein gültiger Pfad im Dateisystem.
     </span>
    </dd>
   
   
    <dt><code class="parameter">mode</code></dt>
    <dd>
     <span class="simpara">
      Das ist <code class="literal">r</code> für lesenden Zugriff, <code class="literal">w</code>
      für lesenden und schreibenden Zugriff auf eine existierende Datenbank,
      <code class="literal">c</code> für lesenden und schreibenden Zugriff und
      Erstellen der Datenbank, falls sie noch nicht existiert, und
      <code class="literal">n</code> für das Erstellen einer Datenbank, bzw. deren
      Zurücksetzen auf die Größe 0, falls sie schon existiert, und lesenden
      und schreibenden Zugriff. Die Datenbank wird im BTree-Modus erzeugt.
      Andere Modi, wie Hash oder Queue, werden nicht unterstützt.
     </span>
     <span class="simpara">
      Zusätzlich kann mit dem nächsten Buchstaben die Datenbank-Sperrmethode
      festgelegt werden. Verwenden Sie <code class="literal">l</code>, um
      die Datenbank mit einer <var class="filename">.lck</var>-Datei zu sperren, oder
      <code class="literal">d</code>, um die Datenbank-Datei selbst zu sperren. Es ist
      wichtig, dass alle Ihre Anwendungen das einheitlich machen.
     </span>
     <span class="simpara">
      Falls Sie den Zugriff testen wollen, ohne auf die Sperrung zu warten,
      können Sie <code class="literal">t</code> als dritten Buchstaben anfügen. Wenn
      Sie sich absolut sicher sind, dass Sie keine Datenbanksperre benötigen,
      können Sie statt <code class="literal">l</code> oder <code class="literal">d</code>
      <code class="literal">-</code> verwenden. Wenn weder <code class="literal">d</code> oder
      <code class="literal">l</code> noch <code class="literal">-</code> verwendet werden, sperrt
      dba die Datenbank-Datei wie bei Verwendung von <code class="literal">d</code>.
     </span>
     <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
      <p class="para">
       Es kann jeweils nur einen Schreibzugriff auf eine Datenbank-Datei
       geben. Wenn dba auf einem Webserver verwendet wird und mehr als eine
       Anfrage Schreibzugriff benötigt, kann nur einer nach dem anderen
       erledigt werden. Auch das Lesen ist während des Schreibens nicht
       erlaubt. Die DBA-Erweiterung verwendet Sperren, um dies zu verhindern.
       Siehe folgende Tabelle:
       <table class="doctable table">
        <caption><strong>DBA-Sperrung</strong></caption>
        
         <thead>
          <tr>
           <th>schon geöffnet</th>
           <th><code class="parameter">mode</code> = &quot;rl&quot;</th>
           <th><code class="parameter">mode</code> = &quot;rlt&quot;</th>
           <th><code class="parameter">mode</code> = &quot;wl&quot;</th>
           <th><code class="parameter">mode</code> = &quot;wlt&quot;</th>
           <th><code class="parameter">mode</code> = &quot;rd&quot;</th>
           <th><code class="parameter">mode</code> = &quot;rdt&quot;</th>
           <th><code class="parameter">mode</code> = &quot;wd&quot;</th>
           <th><code class="parameter">mode</code> = &quot;wdt&quot;</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>nicht geöffnet</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> = &quot;rl&quot;</td>
           <td>OK</td>
           <td>OK</td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
          </tr>

          <tr>
           <td><code class="parameter">mode</code> = &quot;wl&quot;</td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
          </tr>

          <tr>
           <td><code class="parameter">mode</code> = &quot;rd&quot;</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>OK</td>
           <td>OK</td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
          </tr>

          <tr>
           <td><code class="parameter">mode</code> = &quot;wd&quot;</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>unzulässig</td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
           <td>warten</td>
           <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
          </tr>

         </tbody>
        
       </table>

       <ul class="simplelist">
        <li>OK: der zweite Aufruf ist erfolgreich.</li>
        <li>warten: der zweite Aufruf wartet bis für den ersten <span class="function"><a href="function.dba-close.php" class="function">dba_close()</a></span> aufgerufen wird.</li>
        <li><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>: der zweite Aufruf gibt <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurück.</li>
        <li>unzulässig: Sie dürfen beim Parameter <code class="parameter">mode</code> die Modifikatoren <code class="literal">&quot;l&quot;</code> und <code class="literal">&quot;d&quot;</code> nicht zusammen verwenden.</li>
       </ul>
      </p>
     </p></blockquote>
    </dd>
   
   
    <dt><code class="parameter">handler</code></dt>
    <dd>
     <span class="simpara">
      Der Name des <a href="dba.requirements.php" class="link">Handler</a>s, der für
      den Zugriff auf <code class="parameter">path</code> benutzt werden soll. Er
      bekommt alle optionalen Argumente übergeben, die der Funktion
      <span class="function"><strong>dba_open()</strong></span> mitgegeben wurden, und kann damit in
      deren Name verfahren. Wenn <code class="parameter">handler</code> <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> ist,
      wird der Standard-Handler aufgerufen.
     </span>
    </dd>
   
   
    <dt><code class="parameter">permission</code></dt>
    <dd>
     <span class="simpara">
      Ein optionaler <a href="language.types.integer.php" class="link">Integer</a>-Parameter, der an den Treiber übergeben wird.
      Er hat dieselbe Bedeutung wie der Parameter
      <code class="literal">permissions</code> bei <span class="function"><a href="function.chmod.php" class="function">chmod()</a></span>. Der
      Standardwert ist <code class="literal">0644</code>.
     </span>
     <span class="simpara">
      Der Parameter <code class="parameter">permission</code> wird vom
      <code class="literal">db1</code>-, <code class="literal">db2</code>-,
      <code class="literal">db3</code>-, <code class="literal">db4</code>-,
      <code class="literal">dbm</code>-, <code class="literal">gdbm</code>-,
      <code class="literal">ndbm</code>- und <code class="literal">lmdb</code>-Treiber
      unterstützt.
     </span>
    </dd>
   
   
    <dt><code class="parameter">map_size</code></dt>
    <dd>
     <span class="simpara">
      Ein optionaler <a href="language.types.integer.php" class="link">Integer</a>-Parameter, der an den Treiber übergeben wird.
      Sein Wert sollte ein Vielfaches der Größe einer Speicherseite (Page
      Size) des Betriebssystems sein. Wenn Null angegeben wird, wird die
      Standard-Map-Size verwendet.
     </span>
     <span class="simpara">
      Der Parameter <code class="parameter">map_size</code> wird nur vom
      <code class="literal">lmdb</code>-Treiber akzeptiert.
     </span>
    </dd>
   
   
    <dt><code class="parameter">flags</code></dt>
    <dd>
     <span class="simpara">
      Die Flags, die an den Datenbanktreiber übergeben werden. Falls <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
      werden die Standard-Flags bereitgestellt. Derzeit unterstützt nur der
      LMDB-Treiber die Flags <strong><code><a href="dba.constants.php#constant.dba-lmdb-use-sub-dir">DBA_LMDB_USE_SUB_DIR</a></code></strong> und
      <strong><code><a href="dba.constants.php#constant.dba-lmdb-no-sub-dir">DBA_LMDB_NO_SUB_DIR</a></code></strong>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.dba-open-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   Gibt bei Erfolg eine Instanz von <span class="classname"><a href="class.dba-connection.php" class="classname">Dba\Connection</a></span>
   zurück. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.dba-open-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="simpara">
   Wenn <code class="parameter">handler</code> <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> ist, aber kein Standard-Handler
   zur Verfügung steht, wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben und ein Fehler der Stufe
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> ausgegeben.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       Gibt nun eine Instanz von <span class="classname"><a href="class.dba-connection.php" class="classname">Dba\Connection</a></span> zurück;
       zuvor wurde eine <a href="language.types.resource.php" class="link">Ressource</a> zurückgegeben.
      </td>
     </tr>

     <tr>
      <td>8.2.0</td>
      <td>
       Der Parameter <code class="parameter">flags</code> wurde hinzugefügt.
      </td>
     </tr>

     <tr>
      <td>8.2.0</td>
      <td>
       Der Parameter <code class="parameter">handler</code> ist nun nullable
       (akzeptiert den <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>-Wert).
      </td>
     </tr>

     <tr>
      <td>7.3.14, 7.4.2</td>
      <td>
       Der <code class="literal">lmdb</code>-Treiber unterstützt nun zusätzlich den
       Parmeter <code class="parameter">map_size</code>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.dba-open-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.dba-popen.php" class="function" rel="rdfs-seeAlso">dba_popen()</a> - &Ouml;ffnet eine persistente Datenbank-Verbindung</span></li>
   <li><span class="function"><a href="function.dba-close.php" class="function" rel="rdfs-seeAlso">dba_close()</a> - Schlie&szlig;t eine DBA-Datenbank</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>