<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >DBM Functions [deprecated]</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="dbase_replace_record" HREF="function.dbase-replace-record.html"><LINK REL="NEXT" TITLE="dblist" HREF="function.dblist.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.dbase-replace-record.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.dblist.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.dbm" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XXVI. DBM Functions [deprecated]</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN34458" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.intro" >简介</A ></H1 ><P > These functions allow you to store records stored in a dbm-style database. This type of database (supported by the Berkeley DB, <A HREF="ftp://ftp.gnu.org/pub/gnu/gdbm/" TARGET="_top" >GDBM</A >, and some system libraries, as well as a built-in flatfile library) stores key/value pairs (as opposed to the full-blown records supported by relational databases). </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > DBM support is deprecated and you are encouraged to use the <A HREF="ref.dba.html" >Database (dbm-style) abstraction layer functions</A > instead. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > This extension has been removed from PHP and is no longer available as of PHP 5.0.0. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.required" >需求</A ></H1 ><P > To use this functions you have to compile PHP with support for an underlying database. See the <A HREF="ref.dba.html#dba.requirements" >list</A > of supported Databases. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.installation" >安装</A ></H1 ><P > In order to use these functions, you must compile PHP with dbm support by using the <CODE CLASS="option" >--with-db</CODE > option. In addition you must ensure <A HREF="ref.dba.html#dba.installation" >support</A > for an underlying database or you can use some system libraries. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.runtime" >运行时配置</A ></H1 ><P >本扩展模块在 <TT CLASS="filename" >php.ini</TT > 中未定义任何配置选项。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.resources" >资源类型</A ></H1 ><P > The function <A HREF="function.dbmopen.html" ><B CLASS="function" >dbmopen()</B ></A > returns an database identifier which is used by the other dbm-functions. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.constants" >预定义常量</A ></H1 ><P >本扩展模块未定义任何常量。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="dbm.examples" >范例</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN34491" ></A ><P ><B >例 1. DBM example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />$dbm </font><font color="#007700">= </font><font color="#0000BB">dbmopen</font><font color="#007700">(</font><font color="#DD0000">"lastseen"</font><font color="#007700">, </font><font color="#DD0000">"w"</font><font color="#007700">);<br />if (</font><font color="#0000BB">dbmexists</font><font color="#007700">(</font><font color="#0000BB">$dbm</font><font color="#007700">, </font><font color="#0000BB">$userid</font><font color="#007700">)) {<br /> </font><font color="#0000BB">$last_seen </font><font color="#007700">= </font><font color="#0000BB">dbmfetch</font><font color="#007700">(</font><font color="#0000BB">$dbm</font><font color="#007700">, </font><font color="#0000BB">$userid</font><font color="#007700">);<br />} else {<br /> </font><font color="#0000BB">dbminsert</font><font color="#007700">(</font><font color="#0000BB">$dbm</font><font color="#007700">, </font><font color="#0000BB">$userid</font><font color="#007700">, </font><font color="#0000BB">time</font><font color="#007700">());<br />}<br /></font><font color="#0000BB">do_stuff</font><font color="#007700">();<br /></font><font color="#0000BB">dbmreplace</font><font color="#007700">(</font><font color="#0000BB">$dbm</font><font color="#007700">, </font><font color="#0000BB">$userid</font><font color="#007700">, </font><font color="#0000BB">time</font><font color="#007700">());<br /></font><font color="#0000BB">dbmclose</font><font color="#007700">(</font><font color="#0000BB">$dbm</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.dblist.html" >dblist</A > -- Describes the DBM-compatible library being used</DT ><DT ><A HREF="function.dbmclose.html" >dbmclose</A > -- Closes a dbm database</DT ><DT ><A HREF="function.dbmdelete.html" >dbmdelete</A > -- Deletes the value for a key from a DBM database</DT ><DT ><A HREF="function.dbmexists.html" >dbmexists</A > -- Tells if a value exists for a key in a DBM database</DT ><DT ><A HREF="function.dbmfetch.html" >dbmfetch</A > -- Fetches a value for a key from a DBM database</DT ><DT ><A HREF="function.dbmfirstkey.html" >dbmfirstkey</A > -- Retrieves the first key from a DBM database</DT ><DT ><A HREF="function.dbminsert.html" >dbminsert</A > -- Inserts a value for a key in a DBM database</DT ><DT ><A HREF="function.dbmnextkey.html" >dbmnextkey</A > -- </DT ><DT ><A HREF="function.dbmopen.html" >dbmopen</A > -- Opens a DBM database</DT ><DT ><A HREF="function.dbmreplace.html" >dbmreplace</A > -- Replaces the value for a key in a DBM database</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.dbase-replace-record.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.dblist.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >dbase_replace_record</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >dblist</TD ></TR ></TABLE ></DIV ></BODY ></HTML >