• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Using Berkeley DB with PHP</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10    <link rel="up" href="ext.html" title="Chapter��21.�� Berkeley DB Extensions" />
11    <link rel="prev" href="ext_perl.html" title="Using Berkeley DB with Perl" />
12    <link rel="next" href="dumpload.html" title="Chapter��22.�� Dumping and Reloading Databases" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Using Berkeley DB with PHP</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="ext_perl.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��21.��
23		Berkeley DB Extensions
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="dumpload.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="ext_php"></a>Using Berkeley DB with PHP</h2>
35          </div>
36        </div>
37      </div>
38      <p>A PHP 4 extension for this release of Berkeley DB is included in the
39distribution package.  It can either either link directly against the
40installed Berkeley DB library (which is necessary for running in a
41non-Apache/mod_php4 environment), or against mod_db4, which provides
42additional safety when running under Apache/mod_php4.</p>
43      <p>The PHP extension provides the following classes, which mirror the
44standard Berkeley DB C++ API.</p>
45      <pre class="programlisting">class Db4Env {
46	function Db4Env($flags = 0) {}
47	function close($flags = 0) {}
48	function dbremove($txn, $filename, $database = null, $flags = 0) {}
49	function dbrename($txn, $file, $database, $new_database, $flags = 0) {}
50	function open($home, $flags = DB_CREATE  | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN, $mode = 0666) {}
51	function remove($home, $flags = 0) {}
52	function set_data_dir($directory) {}
53	function txn_begin($parent_txn = null, $flags = 0) {}
54	function txn_checkpoint($kbytes, $minutes, $flags = 0) {}
55}
56
57class Db4 {
58	function Db4($dbenv = null) {}	// create a new Db4 object using the optional DbEnv
59	function open($txn = null, $file = null, $database = null, $flags = DB_CREATE, $mode = 0) {}
60	function close() {}
61	function del($key, $txn = null) {}
62	function get($key, $txn = null, $flags = 0) {}
63	function pget($key, &amp;$pkey, $txn = null, $flags = 0) {}
64	function get_type() {}	// returns the stringified database type name
65	function stat($txn = null, $flags = 0) {} // returns statistics as an as
66	function join($cursor_list, $flags = 0) {}
67	function sync() {}
68	function truncate($txn = null, $flags = 0) {}
69	function cursor($txn = null, flags = 0) {}
70}
71
72class Db4Txn {
73	function abort() {}
74	function commit() {}
75	function discard() {}
76	function id() {}
77	function set_timeout($timeout, $flags = 0) {}
78}
79
80class Db4Cursor {
81	function close() {}
82	function count() {}
83	function del() {}
84	function dup($flags = 0) {}
85	function get($key, $flags = 0) {}
86	function pget($key, &amp;$primary_key, $flags = 0) {}
87	function put($key, $data, $flags = 0) {}
88}</pre>
89      <p>The PHP extension attempts to be "smart" for you by:</p>
90      <div class="orderedlist">
91        <ol type="1">
92          <li>Auto-committing operations on transactional databases if no explicit
93Db4Txn object is specified.</li>
94          <li>Performing reference and dependency checking to insure that all
95resources are closed in the correct order.</li>
96          <li>Supplying default values for flags.</li>
97        </ol>
98      </div>
99      <p>To install this PHP module linked against the mod_db4 framework, perform
100the following steps:</p>
101      <pre class="programlisting">% phpize
102% ./configure --with-db4=[Berkeley DB library installation directory] \
103	--with-mod_db4=$APACHE_INCLUDEDIR
104% make
105% make install</pre>
106      <p>Then, in your php.ini file add the following:</p>
107      <pre class="programlisting">extension=db4.so</pre>
108      <p>This extension will now only run in a SAPI linked into Apache httpd
109(mod_php4, most likely), and will take advantage of all of its
110auto-recovery and handle-caching facilities.</p>
111      <p>To install this php module linked against the Berkeley DB library and not the
112mod_db4 framework, perform the following steps:</p>
113      <pre class="programlisting">% phpize
114% ./configure --with-db4=[Berkeley DB library installation directory]
115% make
116% make install</pre>
117      <p>Then in your php.ini file add:</p>
118      <pre class="programlisting">extension=db4.so</pre>
119    </div>
120    <div class="navfooter">
121      <hr />
122      <table width="100%" summary="Navigation footer">
123        <tr>
124          <td width="40%" align="left"><a accesskey="p" href="ext_perl.html">Prev</a>��</td>
125          <td width="20%" align="center">
126            <a accesskey="u" href="ext.html">Up</a>
127          </td>
128          <td width="40%" align="right">��<a accesskey="n" href="dumpload.html">Next</a></td>
129        </tr>
130        <tr>
131          <td width="40%" align="left" valign="top">Using Berkeley DB with Perl��</td>
132          <td width="20%" align="center">
133            <a accesskey="h" href="index.html">Home</a>
134          </td>
135          <td width="40%" align="right" valign="top">��Chapter��22.��
136		Dumping and Reloading Databases
137        </td>
138        </tr>
139      </table>
140    </div>
141  </body>
142</html>
143