<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.dba-popen" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>dba_popen</refname>
  <refpurpose>Open database persistently</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type class="union"><type>resource</type><type>false</type></type><methodname>dba_popen</methodname>
   <methodparam><type>string</type><parameter>path</parameter></methodparam>
   <methodparam><type>string</type><parameter>mode</parameter></methodparam>
   <methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>handler</parameter><initializer>&null;</initializer></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>permission</parameter><initializer>0644</initializer></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>map_size</parameter><initializer>0</initializer></methodparam>
   <methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>flags</parameter><initializer>&null;</initializer></methodparam>
  </methodsynopsis>
  <para>
   <function>dba_popen</function> establishes a persistent database instance
   for <parameter>path</parameter> with <parameter>mode</parameter> using
   <parameter>handler</parameter>.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>path</parameter></term>
     <listitem>
      <para>
       Commonly a regular path in your filesystem.
     </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>mode</parameter></term>
     <listitem>
      <para>
       It is <literal>r</literal> for read access, <literal>w</literal> for
       read/write access to an already existing database, <literal>c</literal>
       for read/write access and database creation if it doesn't currently exist,
       and <literal>n</literal> for create, truncate and read/write access.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>handler</parameter></term>
     <listitem>
      <para>
       The name of the <link linkend="dba.requirements">handler</link> which
       shall be used for accessing <parameter>path</parameter>. It is passed 
       all optional parameters given to <function>dba_popen</function> and 
       can act on behalf of them. If <parameter>handler</parameter> is &null;,
       then the default handler is invoked.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>permission</parameter></term>
     <listitem>
      <para>
       Optional &integer; parameter which is passed to the driver. It has the same meaning as
       the <parameter>permissions</parameter> parameter of <function>chmod</function>,
       and defaults to <literal>0644</literal>.
      </para>
      <para>
       The <literal>db1</literal>, <literal>db2</literal>, <literal>db3</literal>,
       <literal>db4</literal>, <literal>dbm</literal>, <literal>gdbm</literal>,
       <literal>ndbm</literal>, and <literal>lmdb</literal> drivers support the
       <parameter>permission</parameter> parameter.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>map_size</parameter></term>
     <listitem>
      <para>
       Optional &integer; 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.
      </para>
      <para>
       The <literal>lmdb</literal> driver accepts the <parameter>map_size</parameter> parameter.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>flags</parameter></term>
     <listitem>
      <para>
       Allows to pass flags to the DB drivers. Currently, only LMDB with
       <constant>DBA_LMDB_USE_SUB_DIR</constant> and <constant>DBA_LMDB_NO_SUB_DIR</constant> are supported.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a positive handle on success&return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   &false; is returned and an <constant>E_WARNING</constant> level error is issued when
   <parameter>handler</parameter> is &null;, but there is no default handler.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <informaltable>
   <tgroup cols="2">
    <thead>
     <row>
      <entry>&Version;</entry>
      <entry>&Description;</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry>8.2.0</entry>
      <entry>
       <parameter>flags</parameter> is added.
      </entry>
     </row>
     <row>
      <entry>8.1.0</entry>
      <entry>
       <parameter>handler</parameter> is now nullable.
      </entry>
     </row>
     <row>
      <entry>7.3.14, 7.4.2</entry>
      <entry>
       The <literal>lmdb</literal> driver now supports an additional <parameter>map_size</parameter>
       parameter.
      </entry>
     </row>
    </tbody>
   </tgroup>
  </informaltable>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>dba_open</function></member>
    <member><function>dba_close</function></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
