php.html   [plain text]


<!--$Id: php.so,v 10.3 2004/10/18 17:08:43 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Using Berkeley DB with PHP</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Extensions</dl></b></td>
<td align=right><a href="../ext/perl.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../dumpload/utility.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Using Berkeley DB with PHP</b></p>
<p>A PHP 4 extension for this release of Berkeley DB is included in the
distribution package.  It can either either link directly against the
installed Berkeley DB library (which is necessary for running in a
non-Apache/mod_php4 environment), or against mod_db4, which provides
additional safety when running under Apache/mod_php4.</p>
<p>The PHP extension provides the following classes, which mirror the
standard Berkeley DB C++ API.</p>
<blockquote><pre>class Db4Env {
<blockquote><pre>function Db4Env($flags = 0) {}
function close($flags = 0) {}
function dbremove($txn, $filename, $database = null, $flags = 0) {}
function dbrename($txn, $file, $database, $new_database, $flags = 0) {}
function open($home, $flags = DB_CREATE  | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN, $mode = 0666) {}
function remove($home, $flags = 0) {}
function set_data_dir($directory) {}
function txn_begin($parent_txn = null, $flags = 0) {}
function txn_checkpoint($kbytes, $minutes, $flags = 0) {}</pre></blockquote>
}
<p>
class Db4 {
<blockquote><pre>function Db4($dbenv = null) {}	// create a new Db4 object using the optional DbEnv
function open($txn = null, $file = null, $database = null, $flags = DB_CREATE, $mode = 0) {}
function close() {}
function del($key, $txn = null) {}
function get($key, $txn = null, $flags = 0) {}
function pget($key, &$pkey, $txn = null, $flags = 0) {}
function get_type() {}	// returns the stringified database type name
function stat($txn = null, $flags = 0) {} // returns statistics as an as
function join($cursor_list, $flags = 0) {}
function sync() {}
function truncate($txn = null, $flags = 0) {}
function cursor($txn = null, flags = 0) {}</pre></blockquote>
}
<p>
class Db4Txn {
<blockquote><pre>function abort() {}
function commit() {}
function discard() {
function id() {}
function set_timeout($timeout, $flags = 0) {}</pre></blockquote>
}
<p>
class Db4Cursor {
<blockquote><pre>function close() {}
function count() {}
function del() {}
function dup($flags = 0) {}
function get($key, $flags = 0) {}
function pget($key, &$primary_key, $flags = 0) {}
function put($key, $data, $flags = 0) {}</pre></blockquote>
}</pre></blockquote>
<p>The PHP extension attempts to be "smart" for you by:</p>
<ol>
<p><li>Auto-committing operations on transactional databases if no explicit
Db4Txn object is specified.
<p><li>Performing reference and dependency checking to insure that all
resources are closed in the correct order.
<p><li>Supplying default values for flags.
</ol>
<p>To install this PHP module linked against the mod_db4 framework, perform
the following steps:</p>
<blockquote><pre>% phpize
% ./configure --with-db4=[Berkeley DB library installation directory] \
	--with-mod_db4=$APACHE_INCLUDEDIR
% make
% make install</pre></blockquote>
<p>Then, in your php.ini file add the following:</p>
<blockquote><pre>extension=db4.so</pre></blockquote>
<p>This extension will now only run in a SAPI linked into Apache httpd
(mod_php4, most likely), and will take advantage of all of its
auto-recovery and handle-caching facilities.</p>
<p>To install this php module linked against the Berkeley DB library and not the
mod_db4 framework, perform the following steps:</p>
<blockquote><pre>% phpize
% ./configure --with-db4=[Berkeley DB library installation directory]
% make
% make install</pre></blockquote>
<p>Then in your php.ini file add:</p>
<blockquote><pre>extension=db4.so</pre></blockquote>
<table width="100%"><tr><td><br></td><td align=right><a href="../ext/perl.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../dumpload/utility.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>