| 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 22. 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 23. Dumping and Reloading Databases" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Using Berkeley DB with PHP</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="ext_perl.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 22. |
| 26 | Berkeley DB Extensions |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="dumpload.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="ext_php"></a>Using Berkeley DB with PHP</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>A PHP 4 extension for this release of Berkeley DB is included in the |
| 42 | distribution package. It can either either link directly against the |
| 43 | installed Berkeley DB library (which is necessary for running in a |
| 44 | non-Apache/mod_php4 environment), or against mod_db4, which provides |
| 45 | additional safety when running under Apache/mod_php4.</p> |
| 46 | <p> |
| 47 | For installation instructions, see the <code class="filename">INSTALL</code> file that |
| 48 | resides in the <code class="literal">lang/php_db4</code> directory in your |
| 49 | Berkeley DB distribution. |
| 50 | </p> |
| 51 | <p>The PHP extension provides the following classes, which mirror the |
| 52 | standard Berkeley DB C++ API.</p> |
| 53 | <pre class="programlisting">class Db4Env { |
| 54 | function Db4Env($flags = 0) {} |
| 55 | function close($flags = 0) {} |
| 56 | function dbremove($txn, $filename, $database = null, $flags = 0) {} |
| 57 | function dbrename($txn, $file, $database, $new_database, |
| 58 | $flags = 0) {} |
| 59 | function open($home, $flags = DB_CREATE | DB_INIT_LOCK | |
| 60 | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN, |
| 61 | $mode = 0666) {} |
| 62 | function remove($home, $flags = 0) {} |
| 63 | function set_data_dir($directory) {} |
| 64 | function txn_begin($parent_txn = null, $flags = 0) {} |
| 65 | function txn_checkpoint($kbytes, $minutes, $flags = 0) {} |
| 66 | } |
| 67 | |
| 68 | class Db4 { |
| 69 | function Db4($dbenv = null) {} // create a new Db4 object using |
| 70 | // the optional DbEnv |
| 71 | function open($txn = null, $file = null, $database = null, |
| 72 | $flags = DB_CREATE, $mode = 0) {} |
| 73 | function close() {} |
| 74 | function del($key, $txn = null) {} |
| 75 | function get($key, $txn = null, $flags = 0) {} |
| 76 | function pget($key, &$pkey, $txn = null, $flags = 0) {} |
| 77 | function get_type() {} // returns the stringified |
| 78 | // database type name |
| 79 | function stat($txn = null, $flags = 0) {} // returns statistics as |
| 80 | // an as |
| 81 | function join($cursor_list, $flags = 0) {} |
| 82 | function sync() {} |
| 83 | function truncate($txn = null, $flags = 0) {} |
| 84 | function cursor($txn = null, flags = 0) {} |
| 85 | } |
| 86 | |
| 87 | class Db4Txn { |
| 88 | function abort() {} |
| 89 | function commit() {} |
| 90 | function discard() {} |
| 91 | function id() {} |
| 92 | function set_timeout($timeout, $flags = 0) {} |
| 93 | } |
| 94 | |
| 95 | class Db4Cursor { |
| 96 | function close() {} |
| 97 | function count() {} |
| 98 | function del() {} |
| 99 | function dup($flags = 0) {} |
| 100 | function get($key, $flags = 0) {} |
| 101 | function pget($key, &$primary_key, $flags = 0) {} |
| 102 | function put($key, $data, $flags = 0) {} |
| 103 | }</pre> |
| 104 | <p>The PHP extension attempts to be "smart" for you by:</p> |
| 105 | <div class="orderedlist"> |
| 106 | <ol type="1"> |
| 107 | <li>Auto-committing operations on transactional databases if no explicit |
| 108 | Db4Txn object is specified.</li> |
| 109 | <li>Performing reference and dependency checking to insure that all |
| 110 | resources are closed in the correct order.</li> |
| 111 | <li>Supplying default values for flags.</li> |
| 112 | </ol> |
| 113 | </div> |
| 114 | </div> |
| 115 | <div class="navfooter"> |
| 116 | <hr /> |
| 117 | <table width="100%" summary="Navigation footer"> |
| 118 | <tr> |
| 119 | <td width="40%" align="left"><a accesskey="p" href="ext_perl.html">Prev</a> </td> |
| 120 | <td width="20%" align="center"> |
| 121 | <a accesskey="u" href="ext.html">Up</a> |
| 122 | </td> |
| 123 | <td width="40%" align="right"> <a accesskey="n" href="dumpload.html">Next</a></td> |
| 124 | </tr> |
| 125 | <tr> |
| 126 | <td width="40%" align="left" valign="top">Using Berkeley DB with Perl </td> |
| 127 | <td width="20%" align="center"> |
| 128 | <a accesskey="h" href="index.html">Home</a> |
| 129 | </td> |
| 130 | <td width="40%" align="right" valign="top"> Chapter 23. |
| 131 | Dumping and Reloading Databases |
| 132 | </td> |
| 133 | </tr> |
| 134 | </table> |
| 135 | </div> |
| 136 | </body> |
| 137 | </html> |