📄 mod_dbd.html.en
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --><title>mod_dbd - Apache HTTP Server</title><link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /><link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link href="../images/favicon.ico" rel="shortcut icon" /></head><body><div id="page-header"><p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p><p class="apache">Apache HTTP Server Version 2.2</p><img alt="" src="../images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div><div id="page-content"><div id="preamble"><h1>Apache Module mod_dbd</h1><div class="toplang"><p><span>Available Languages: </span><a href="../en/mod/mod_dbd.html" title="English"> en </a></p></div><table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Manages SQL database connections</td></tr><tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="module-dict.html#ModuleIdentifier">Module營dentifier:</a></th><td>dbd_module</td></tr><tr><th><a href="module-dict.html#SourceFile">Source燜ile:</a></th><td>mod_dbd.c</td></tr><tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Version 2.1 and later</td></tr></table><h3>Summary</h3> <p><code class="module"><a href="../mod/mod_dbd.html">mod_dbd</a></code> manages SQL database connections using <a class="glossarylink" href="../glossary.html#apr" title="see glossary">APR</a>. It provides database connections on request to modules requiring SQL database functions, and takes care of managing databases with optimal efficiency and scalability for both threaded and non-threaded MPMs. For details, see the <a href="http://apr.apache.org/">APR</a> website and this overview of the <a href="http://people.apache.org/~niq/dbd.html">Apache DBD Framework</a> by its original developer.</p></div><div id="quickview"><h3 class="directives">Directives</h3><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#dbdexptime">DBDExptime</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdkeep">DBDKeep</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdmax">DBDMax</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdmin">DBDMin</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdparams">DBDParams</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdpersist">DBDPersist</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdpreparesql">DBDPrepareSQL</a></li><li><img alt="" src="../images/down.gif" /> <a href="#dbdriver">DBDriver</a></li></ul><h3>Topics</h3><ul id="topics"><li><img alt="" src="../images/down.gif" /> <a href="#pooling">Connection Pooling</a></li><li><img alt="" src="../images/down.gif" /> <a href="#API">Apache DBD API</a></li><li><img alt="" src="../images/down.gif" /> <a href="#prepared">SQL Prepared Statements</a></li></ul><h3>See also</h3><ul class="seealso"><li><a href="../misc/password_encryptions.html">Password Formats</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="pooling" id="pooling">Connection Pooling</a></h2> <p>This module manages database connections, in a manner optimised for the platform. On non-threaded platforms, it provides a persistent connection in the manner of classic LAMP (Linux, Apache, Mysql, Perl/PHP/Python). On threaded platform, it provides an altogether more scalable and efficient <em>connection pool</em>, as described in <a href="http://www.apachetutor.org/dev/reslist">this article at ApacheTutor</a>. Note that <code class="module"><a href="../mod/mod_dbd.html">mod_dbd</a></code> supersedes the modules presented in that article.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="API" id="API">Apache DBD API</a></h2> <p><code class="module"><a href="../mod/mod_dbd.html">mod_dbd</a></code> exports five functions for other modules to use. The API is as follows:</p> <div class="example"><pre><code>typedef struct { apr_dbd_t *handle; apr_dbd_driver_t *driver; apr_hash_t *prepared;} ap_dbd_t;/* Export functions to access the database *//* acquire a connection that MUST be explicitly closed. * Returns NULL on error */AP_DECLARE(ap_dbd_t*) ap_dbd_open(apr_pool_t*, server_rec*);/* release a connection acquired with ap_dbd_open */AP_DECLARE(void) ap_dbd_close(server_rec*, ap_dbd_t*);/* acquire a connection that will have the lifetime of a request * and MUST NOT be explicitly closed. Return NULL on error. * This is the preferred function for most applications. */AP_DECLARE(ap_dbd_t*) ap_dbd_acquire(request_rec*);/* acquire a connection that will have the lifetime of a connection * and MUST NOT be explicitly closed. Return NULL on error. */AP_DECLARE(ap_dbd_t*) ap_dbd_cacquire(request_rec*);/* Prepare a statement for use by a client module */AP_DECLARE(void) ap_dbd_prepare(server_rec*, const char*, const char*);/* Also export them as optional functions for modules that prefer it */APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*));APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*));APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));</code></pre></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="prepared" id="prepared">SQL Prepared Statements</a></h2> <p><code class="module"><a href="../mod/mod_dbd.html">mod_dbd</a></code> supports SQL prepared statements on behalf of modules that may wish to use them. Each prepared statement must be assigned a name (label), and they are stored in a hash: the <code>prepared</code> field of an <code>ap_dbd_t</code>. Hash entries are of type <code>apr_dbd_prepared_t</code> and can be used in any of the apr_dbd prepared statement SQL query or select commands.</p> <p>It is up to dbd user modules to use the prepared statements and document what statements can be specified in httpd.conf, or to provide their own directives and use <code>ap_dbd_prepare</code>.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="DBDExptime" id="DBDExptime">DBDExptime</a> <a name="dbdexptime" id="dbdexptime">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Keepalive time for idle connections</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DBDExptime <var>time-in-seconds</var></code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DBDExptime 300</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -