<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.dba-popen.php',
    1 => 'dba_popen',
    2 => 'Open database persistently',
  ),
  'up' => 
  array (
    0 => 'ref.dba.php',
    1 => 'DBA Functions',
  ),
  'prev' => 
  array (
    0 => 'function.dba-optimize.php',
    1 => 'dba_optimize',
  ),
  'next' => 
  array (
    0 => 'function.dba-replace.php',
    1 => 'dba_replace',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/dba/functions/dba-popen.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.dba-popen" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dba_popen</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">dba_popen</span> &mdash; <span class="dc-title">Open database persistently</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dba-popen-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>dba_popen</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_popen()</strong></span> establishes a persistent 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 parameters" id="refsect1-function.dba-popen-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">path</code></dt>
    <dd>
     <span class="simpara">
      Commonly a regular path in your filesystem.
    </span>
    </dd>
   
   
    <dt><code class="parameter">mode</code></dt>
    <dd>
     <span class="simpara">
      It is <code class="literal">r</code> for read access, <code class="literal">w</code> for
      read/write access to an already existing database, <code class="literal">c</code>
      for read/write access and database creation if it doesn&#039;t currently exist,
      and <code class="literal">n</code> for create, truncate and read/write access.
     </span>
    </dd>
   
   
    <dt><code class="parameter">handler</code></dt>
    <dd>
     <span class="simpara">
      The name of the <a href="dba.requirements.php" class="link">handler</a> which
      shall be used for accessing <code class="parameter">path</code>. It is passed
      all optional parameters given to <span class="function"><strong>dba_popen()</strong></span> and
      can act on behalf of them. If <code class="parameter">handler</code> is <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
      then the default handler is invoked.
     </span>
    </dd>
   
   
    <dt><code class="parameter">permission</code></dt>
    <dd>
     <span class="simpara">
      Optional <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> parameter which is passed to the driver. It has the same meaning as
      the <code class="parameter">permissions</code> parameter of <span class="function"><a href="function.chmod.php" class="function">chmod()</a></span>,
      and defaults to <code class="literal">0644</code>.
     </span>
     <span class="simpara">
      The <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>, and <code class="literal">lmdb</code> drivers support the
      <code class="parameter">permission</code> parameter.
     </span>
    </dd>
   
   
    <dt><code class="parameter">map_size</code></dt>
    <dd>
     <span class="simpara">
      Optional <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> parameter which is passed to the driver. Its value should be a multiple of the
      page size of the OS, or zero, to use the default mapsize.
     </span>
     <span class="simpara">
      The <code class="literal">lmdb</code> driver accepts the <code class="parameter">map_size</code> parameter.
     </span>
    </dd>
   
   
    <dt><code class="parameter">flags</code></dt>
    <dd>
     <span class="simpara">
      Allows to pass flags to the DB drivers. Currently, only LMDB with
      <strong><code><a href="dba.constants.php#constant.dba-lmdb-use-sub-dir">DBA_LMDB_USE_SUB_DIR</a></code></strong> and <strong><code><a href="dba.constants.php#constant.dba-lmdb-no-sub-dir">DBA_LMDB_NO_SUB_DIR</a></code></strong> are supported.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.dba-popen-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns a <span class="classname"><a href="class.dba-connection.php" class="classname">Dba\Connection</a></span> instance on success or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.dba-popen-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="simpara">
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> is returned and an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> level error is issued when
   <code class="parameter">handler</code> is <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, but there is no default handler.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       Returns a <span class="classname"><a href="class.dba-connection.php" class="classname">Dba\Connection</a></span> instance now;
       previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was returned.
      </td>
     </tr>

     <tr>
      <td>8.2.0</td>
      <td>
       <code class="parameter">flags</code> is added.
      </td>
     </tr>

     <tr>
      <td>8.1.0</td>
      <td>
       <code class="parameter">handler</code> is now nullable.
      </td>
     </tr>

     <tr>
      <td>7.3.14, 7.4.2</td>
      <td>
       The <code class="literal">lmdb</code> driver now supports an additional <code class="parameter">map_size</code>
       parameter.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


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

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