⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dba.examples.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Examples</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="dba.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.dba.html">DBA Functions</a></div> <div class="up"><a href="book.dba.html">DBA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Examples</h1> <div id="dba.example" class="section">  <h2 class="title">Basic usage</h2>   <p class="para">    <div class="example">     <p><b>Example #1 DBA example</b></p>     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dba_open</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp/test.db"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"db2"</span><span style="color: #007700">);<br /><br />if&nbsp;(!</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"dba_open&nbsp;failed\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">dba_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;an&nbsp;example!"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">dba_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">dba_fetch</span><span style="color: #007700">(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dba_delete</span><span style="color: #007700">(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">dba_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p>  <p class="para">   DBA is binary safe and does not have any arbitrary limits.   However, it inherits all limits set by the underlying   database implementation.  </p>  <p class="para">   All file-based databases must provide a way of setting the file   mode of a new created database, if that is possible at all. The   file mode is commonly passed as the fourth argument to   <a href="function.dba-open.html" class="function">dba_open()</a> or <a href="function.dba-popen.html" class="function">dba_popen()</a>.  </p>  <p class="para">   You can access all entries of a database in a linear way by using the   <a href="function.dba-firstkey.html" class="function">dba_firstkey()</a> and <a href="function.dba-nextkey.html" class="function">dba_nextkey()</a>   functions. You may not change the database while traversing it.  </p>   <p class="para">   <div class="example">    <p><b>Example #2 Traversing a database</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;...open&nbsp;database...<br /><br /></span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dba_firstkey</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br /><br />while&nbsp;(</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">!=&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">true</span><span style="color: #007700">)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;remember&nbsp;the&nbsp;key&nbsp;to&nbsp;perform&nbsp;some&nbsp;action&nbsp;later<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$handle_later</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$key</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dba_nextkey</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br />}<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$handle_later&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dba_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="dba.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.dba.html">DBA Functions</a></div> <div class="up"><a href="book.dba.html">DBA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -