2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-07-01 13:07:50 +00:00
|
|
|
<!-- $Revision: 1.24 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<reference id="ref.dba">
|
2004-02-24 08:46:39 +00:00
|
|
|
<title>Database (dbm-style) Abstraction Layer Functions</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<titleabbrev>dba</titleabbrev>
|
|
|
|
|
|
|
|
<partintro>
|
2002-04-25 21:37:34 +00:00
|
|
|
<section id="dba.intro">
|
|
|
|
&reftitle.intro;
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
These functions build the foundation for accessing Berkeley DB
|
|
|
|
style databases.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
This is a general abstraction layer for several file-based databases.
|
|
|
|
As such, functionality is limited to a common subset of features
|
|
|
|
supported by modern databases such as
|
|
|
|
<ulink url="&url.sleepycat;">Sleepycat Software's DB2</ulink>.
|
|
|
|
(This is not to be confused with IBM's DB2 software, which is
|
2004-04-11 15:42:00 +00:00
|
|
|
supported through the <link linkend="ref.uodbc">ODBC functions</link>.)
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
2002-04-25 21:37:34 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="dba.requirements">
|
|
|
|
&reftitle.required;
|
|
|
|
<para>
|
|
|
|
The behaviour of various aspects depends on the implementation of the
|
|
|
|
underlying database. Functions such as <function>dba_optimize</function>
|
|
|
|
and <function>dba_sync</function> will do what they promise for one
|
|
|
|
database and will do nothing for others. You have to download and install
|
|
|
|
supported dba-Handlers.
|
2002-04-15 00:12:54 +00:00
|
|
|
<table>
|
|
|
|
<title>List of DBA handlers</title>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>Handler</entry>
|
|
|
|
<entry>Notes</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>dbm</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
Dbm is the oldest (original) type of Berkeley DB style
|
|
|
|
databases. You should avoid it, if possible. We do not support
|
|
|
|
the compatibility functions built into DB2 and gdbm, because
|
|
|
|
they are only compatible on the source code level, but cannot
|
2002-04-25 21:37:34 +00:00
|
|
|
handle the original dbm format.
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>ndbm</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
Ndbm is a newer type and more flexible than dbm. It still has
|
|
|
|
most of the arbitrary limits of dbm (therefore it is
|
2002-04-25 21:37:34 +00:00
|
|
|
deprecated).
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>gdbm</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
Gdbm is the <ulink url="&url.gdbm;">GNU database
|
2002-04-25 21:37:34 +00:00
|
|
|
manager</ulink>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>db2</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
DB2 is <ulink url="&url.sleepycat;">Sleepycat Software's
|
|
|
|
DB2</ulink>. It is described as "a programmatic toolkit that
|
|
|
|
provides high-performance built-in database support for both
|
2002-04-25 21:37:34 +00:00
|
|
|
standalone and client/server applications.
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>db3</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
DB3 is <ulink url="&url.sleepycat;">Sleepycat Software's
|
2002-04-25 21:37:34 +00:00
|
|
|
DB3</ulink>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2002-11-29 11:32:52 +00:00
|
|
|
<row>
|
|
|
|
<entry><literal>db4</literal></entry>
|
|
|
|
<entry>
|
|
|
|
DB4 is <ulink url="&url.sleepycat;">Sleepycat Software's
|
2004-01-25 12:59:39 +00:00
|
|
|
DB4</ulink>. This is available since PHP 4.3.2.
|
2002-11-29 11:32:52 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2002-04-15 00:12:54 +00:00
|
|
|
<row>
|
2002-04-25 21:37:34 +00:00
|
|
|
<entry><literal>cdb</literal></entry>
|
2002-04-15 00:12:54 +00:00
|
|
|
<entry>
|
|
|
|
Cdb is "a fast, reliable, lightweight package for creating and
|
|
|
|
reading constant databases." It is from the author of qmail and
|
2003-12-31 15:03:12 +00:00
|
|
|
can be found at <ulink url="&url.cdb;">&url.cdb;</ulink>. Since it is
|
2002-11-06 09:48:38 +00:00
|
|
|
constant, we support only reading operations. And since PHP 4.3.0
|
2002-11-05 15:45:38 +00:00
|
|
|
we support writing (not updating) through the internal cdb library.
|
2002-04-15 00:12:54 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2002-11-06 09:24:29 +00:00
|
|
|
<row>
|
|
|
|
<entry><literal>cdb_make</literal></entry>
|
|
|
|
<entry>
|
2002-11-06 09:48:38 +00:00
|
|
|
Since PHP 4.3.0 we support creation (not updating) of cdb files
|
2003-12-15 18:42:07 +00:00
|
|
|
when the bundled cdb library is used.
|
2002-11-06 09:24:29 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry><literal>flatfile</literal></entry>
|
|
|
|
<entry>
|
2002-11-06 09:48:38 +00:00
|
|
|
This is available since PHP 4.3.0 for compatibility with the deprecated
|
2002-11-10 00:36:57 +00:00
|
|
|
<link linkend="ref.dbm">dbm</link> extension only and should be avoided.
|
2002-11-06 09:24:29 +00:00
|
|
|
However you may use this where files were created in this format. That
|
|
|
|
happens when configure could not find any external library.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2003-11-13 09:40:08 +00:00
|
|
|
<row>
|
2003-11-25 18:15:51 +00:00
|
|
|
<entry><literal>inifile</literal></entry>
|
2003-11-13 09:40:08 +00:00
|
|
|
<entry>
|
|
|
|
This is available since PHP 4.3.3 to be able to modify php.ini files
|
2003-12-21 01:23:01 +00:00
|
|
|
from within PHP scripts. When working with ini files you can pass arrays
|
2003-11-13 09:40:08 +00:00
|
|
|
of the form array(0=>group,1=>value_name) or strings of the form
|
|
|
|
"[group]value_name" where group is optional. As the functions
|
|
|
|
<function>dba_firstkey</function> and <function>dba_nextkey</function>
|
|
|
|
return string representations of the key there is a new function
|
|
|
|
<function>dba_key_split</function> available since PHP 5 which allows
|
|
|
|
to convert the string keys into array keys without loosing &false;.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2003-12-23 11:32:31 +00:00
|
|
|
<row>
|
|
|
|
<entry><literal>qdbm</literal></entry>
|
|
|
|
<entry>
|
|
|
|
This is available since PHP 5.0.0. The qdbm library can be loaded from
|
|
|
|
<ulink url="http://qdbm.sourceforge.net">http://qdbm.sourceforge.net</ulink>.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
|
2002-04-15 00:12:54 +00:00
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
2002-04-25 21:37:34 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
When invoking the <function>dba_open</function> or
|
|
|
|
<function>dba_popen</function> functions, one of the
|
|
|
|
handler names must be supplied as an argument. The actually
|
|
|
|
available list of handlers is displayed by invoking
|
2002-11-05 15:45:38 +00:00
|
|
|
<function>phpinfo</function> or <function>dba_handlers</function>.
|
2002-04-25 21:37:34 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2002-11-25 23:49:22 +00:00
|
|
|
&reference.dba.configure;
|
2002-04-25 21:37:34 +00:00
|
|
|
|
|
|
|
<section id="dba.runtime">
|
|
|
|
&reftitle.runtime;
|
|
|
|
&no.config;
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="dba.resources">
|
|
|
|
&reftitle.resources;
|
|
|
|
<para>
|
|
|
|
The functions <function>dba_open</function> and
|
|
|
|
<function>dba_popen</function> return a handle to the specified
|
|
|
|
database file to access which is used by all other dba-function calls.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="dba.constants">
|
|
|
|
&reftitle.constants;
|
|
|
|
&no.constants;
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="dba.examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>DBA example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
$id = dba_open("/tmp/test.db", "n", "db2");
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
if (!$id) {
|
|
|
|
echo "dba_open failed\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
dba_replace("key", "This is an example!", $id);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
if (dba_exists("key", $id)) {
|
|
|
|
echo dba_fetch("key", $id);
|
|
|
|
dba_delete("key", $id);
|
2002-04-15 00:12:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
dba_close($id);
|
2002-04-15 00:12:54 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2002-04-25 21:37:34 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
DBA is binary safe and does not have any arbitrary limits.
|
|
|
|
However, it inherits all limits set by the underlying
|
|
|
|
database implementation.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
All file-based databases must provide a way of setting the file
|
|
|
|
mode of a new created database, if that is possible at all. The
|
|
|
|
file mode is commonly passed as the fourth argument to
|
|
|
|
<function>dba_open</function> or <function>dba_popen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
You can access all entries of a database in a linear way by using the
|
|
|
|
<function>dba_firstkey</function> and <function>dba_nextkey</function>
|
|
|
|
functions. You may not change the database while traversing it.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Traversing a database</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2002-04-25 21:37:34 +00:00
|
|
|
// ...open database...
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
$key = dba_firstkey($id);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
while ($key != false) {
|
2003-12-11 15:42:10 +00:00
|
|
|
if (true) { // remember the key to perform some action later
|
2002-04-15 00:12:54 +00:00
|
|
|
$handle_later[] = $key;
|
|
|
|
}
|
2003-12-15 16:55:22 +00:00
|
|
|
$key = dba_nextkey($id);
|
2002-04-15 00:12:54 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 13:07:50 +00:00
|
|
|
foreach ($handle_later as $val) {
|
|
|
|
dba_delete($val, $id);
|
2004-01-15 12:43:50 +00:00
|
|
|
}
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
2002-04-25 21:37:34 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2002-04-15 00:12:54 +00:00
|
|
|
</partintro>
|
|
|
|
|
|
|
|
&reference.dba.functions;
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
<!-- 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:"../../../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
|
|
|
|
-->
|
|
|
|
|