function.dbase-replace-record.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 133 行
HTML
133 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Replaces a record in a database</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="ref.dbase.html">dBase Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.dbplus.html">DB++</a></div> <div class="up"><a href="ref.dbase.html">dBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.dbase-replace-record" class="refentry"> <div class="refnamediv"> <h1 class="refname">dbase_replace_record</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">dbase_replace_record</span> — <span class="dc-title">Replaces a record in a database</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>dbase_replace_record</b></b></span> ( <span class="methodparam"><span class="type">int</span> <tt class="parameter">$dbase_identifier</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$record</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$record_number</tt></span> )</div> <p class="para rdfs-comment"> Replaces the given record in the database with the given data. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">dbase_identifier</tt></i></span> <dd> <p class="para"> The database link identifier, returned by <a href="function.dbase-open.html" class="function">dbase_open()</a> or <a href="function.dbase-create.html" class="function">dbase_create()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">record</tt></i></span> <dd> <p class="para"> An indexed array of data. The number of items must be equal to the number of fields in the database, otherwise <b>dbase_replace_record()</b> will fail. </p> <blockquote><p><b class="note">Note</b>: If you're using <a href="function.dbase-get-record.html" class="function">dbase_get_record()</a> return value for this parameter, remember to reset the key named <i>deleted</i>. <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">record_number</tt></i></span> <dd> <p class="para"> An integer which spans from 1 to the number of records in the database (as returned by <a href="function.dbase-numrecords.html" class="function">dbase_numrecords()</a>). </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Updating a record in the database</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// open in read-write mode<br /></span><span style="color: #0000BB">$db </span><span style="color: #007700">= </span><span style="color: #0000BB">dbase_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/tmp/test.dbf'</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br />if (</span><span style="color: #0000BB">$db</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// gets the old row<br /> </span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">dbase_get_record_with_names</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// remove the 'deleted' entry<br /> </span><span style="color: #007700">unset(</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'deleted'</span><span style="color: #007700">]);<br /> <br /> </span><span style="color: #FF8000">// Update the date field with the current timestamp<br /> </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'date'</span><span style="color: #007700">] = </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Ymd'</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// Replace the record<br /> </span><span style="color: #0000BB">dbase_replace_record</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">, </span><span style="color: #0000BB">$row</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">dbase_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.dbase-add-record.html" class="function" rel="rdfs-seeAlso">dbase_add_record()</a></li> <li class="member"><a href="function.dbase-delete-record.html" class="function" rel="rdfs-seeAlso">dbase_delete_record()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.dbase.html">dBase Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.dbplus.html">DB++</a></div> <div class="up"><a href="ref.dbase.html">dBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?