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

📄 function.hw-modifyobject.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Modifies object record</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="function.hw-mapid.html">hw_mapid</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.hw-mv.html">hw_mv</a></div> <div class="up"><a href="ref.hw.html">Hyperwave Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.hw-modifyobject" class="refentry"> <div class="refnamediv">  <h1 class="refname">hw_Modifyobject</h1>  <p class="verinfo">(PHP 4)</p><p class="refpurpose"><span class="refname">hw_Modifyobject</span> &mdash; <span class="dc-title">Modifies object record</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>hw_modifyobject</b></b></span>    ( <span class="methodparam"><span class="type">int</span> <tt class="parameter">$connection</tt></span>   , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$object_to_change</tt></span>   , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$remove</tt></span>   , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$add</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt></span>  ] )</div>  <p class="para rdfs-comment">   This command allows to remove, add, or modify individual attributes   of an object record.  The object is specified by the Object ID   <i><tt class="parameter">object_to_change</tt></i>.   In order to modify an attribute one will have to remove   the old one and add a new one. <b>hw_modifyobject()</b>   will always remove the attributes before it adds attributes unless   the value of the attribute to remove is not a string or array.  </p>  <p class="para">   The keys of both arrays are the attributes name. The value of each   array element can either be an array, a string or anything else.   If it is an array   each attribute value is constructed by the key of each element plus   a colon and the value of each element. If it is a string it is taken   as the attribute value. An empty string will result in a complete   removal of that attribute. If the value is neither a string nor an   array but something else, e.g. an integer, no operation at all will   be performed on the attribute. This is necessary if you want to   add a completely new attribute not just a new value for an existing   attribute. If the remove array contained   an empty string for that attribute, the attribute would be tried to be   removed which would fail since it doesn&#039;t exist. The following addition of   a new value for that attribute would also fail. Setting the value   for that attribute to e.g. 0 would not even try to remove it and   the addition will work.  </p>  <p class="para">   If you would like to change the attribute &#039;Name&#039; with the current   value &#039;books&#039; into &#039;articles&#039; you will have to create two arrays   and call <b>hw_modifyobject()</b>.   <div class="example">    <p><b>Example #1 modifying an attribute</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;$connect&nbsp;is&nbsp;an&nbsp;existing&nbsp;connection&nbsp;to&nbsp;the&nbsp;Hyperwave&nbsp;server<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;$objid&nbsp;is&nbsp;the&nbsp;ID&nbsp;of&nbsp;the&nbsp;object&nbsp;to&nbsp;modify<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$remarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"books"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$addarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"articles"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hw_modifyobject</span><span style="color: #007700">(</span><span style="color: #0000BB">$connect</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$objid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$remarr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$addarr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>   In order to delete/add a name=value pair from/to the object record just   pass the remove/add array and set the last/third parameter to an empty   array. If the attribute is the first one with that name to add, set   attribute value in the remove array to an integer.   <div class="example">    <p><b>Example #2 adding a completely new attribute</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;$connect&nbsp;is&nbsp;an&nbsp;existing&nbsp;connection&nbsp;to&nbsp;the&nbsp;Hyperwave&nbsp;server<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;$objid&nbsp;is&nbsp;the&nbsp;ID&nbsp;of&nbsp;the&nbsp;object&nbsp;to&nbsp;modify<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$remarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$addarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"articles"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hw_modifyobject</span><span style="color: #007700">(</span><span style="color: #0000BB">$connect</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$objid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$remarr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$addarr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p>  <p class="para">   <blockquote><p><b class="note">Note</b>:     <span class="simpara">     Multilingual attributes, e.g. &#039;Title&#039;, can be modified in two     ways. Either by providing the attributes value in its native     form &#039;language&#039;:&#039;title&#039; or by providing an array with elements     for each language as described above. The above example would     than be:    </span>   </p></blockquote>   <div class="example">    <p><b>Example #3 modifying Title attribute</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$remarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"en:Books"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$addarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"en:Articles"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hw_modifyobject</span><span style="color: #007700">(</span><span style="color: #0000BB">$connect</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$objid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$remarr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$addarr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>    or   <div class="example">    <p><b>Example #4 modifying Title attribute</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$remarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">"en"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Books"</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$addarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">"en"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Articles"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ge"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"Artikel"</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hw_modifyobject</span><span style="color: #007700">(</span><span style="color: #0000BB">$connect</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$objid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$remarr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$addarr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>   This removes the English title &#039;Books&#039; and adds the English title   &#039;Articles&#039; and the German title &#039;Artikel&#039;.   <div class="example">    <p><b>Example #5 removing attribute</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$remarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$addarr&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"Title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"en:Articles"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hw_modifyobject</span><span style="color: #007700">(</span><span style="color: #0000BB">$connect</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$objid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$remarr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$addarr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>   <blockquote><p><b class="note">Note</b>:     <span class="simpara">     This will remove all attributes with the name &#039;Title&#039; and adds     a new &#039;Title&#039; attribute. This comes in handy if you want to

⌨️ 快捷键说明

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