{"id":432,"date":"2014-04-17T11:29:07","date_gmt":"2014-04-17T03:29:07","guid":{"rendered":"http:\/\/ufqi.com\/blog\/?p=432"},"modified":"2014-10-30T14:12:49","modified_gmt":"2014-10-30T06:12:49","slug":"gmis-updates-20140417","status":"publish","type":"post","link":"https:\/\/ufqi.com\/blog\/gmis-updates-20140417\/","title":{"rendered":"gMIS\u4e3b\u8981\u66f4\u65b0201404"},"content":{"rendered":"<p><a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-gmis\" target=\"_blank\">gMIS <\/a>\u901a\u7528\u7ba1\u7406\u4fe1\u606f\u7cfb\u7edf\uff0c\u6700\u8fd1\u8fdb\u884c\u4e86\u51e0\u4e2a\u4e3b\u8981\u66f4\u65b0\uff1a\u5220\u9664\u8bb0\u5f55\u540e\u4e22\u5931pntc\u7684\u5bfc\u822a\u9875\u5f02\u5e38\uff1b\u521d\u59cb\u5316\u67e5\u8be2\u65f6\u7684\u91cd\u590dSQL\u67e5\u8be2\u95ee\u9898\uff1b\u4e0b\u62c9\u6846\u4ece\u8868\u4e2d\u9009\u62e9options\u65f6\u7684\u7f13\u5b58\u4f18\u5316\u7b49\u3002<\/p>\n<p><strong>1. \u5220\u9664\u8bb0\u5f55\u540e\u7684list\u9875\u9762\u4e22\u5931pntc\uff0c\u8fdb\u800c\u5bfc\u822a\u9875\u5f02\u5e38<\/strong><\/p>\n<p>\u4f7f\u7528gMIS\u90e8\u7f72\u5230\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u9891\u7e41\u9700\u8981\u5220\u9664\u6570\u636e\uff0c\u4e3b\u8981\u5f02\u5e38\u884c\u4e3a\u662f\uff0c\u5728list\u9875\u9762\u65f6\uff0c\u5982\u679c\u5220\u9664\u6389\u4e00\u6761\u8bb0\u5f55\uff0c\u5219\u5f53\u524d\u9875\u9762\u7684\u5bfc\u822a\u7ffb\u9875\u7b49\u529f\u80fd\u663e\u793a\u6b63\u5e38\uff0c\u4f46\u5728\u8fdb\u4e00\u6b65\u70b9\u51fb\u7ffb\u9875\u65f6\uff0c\u7ffb\u9875\u4fe1\u606f\u5168\u90e8\u4e22\u5931\u3002<\/p>\n<p>\u7ecf\u67e5\uff0c\u6d89\u53ca\u5230 class\/pagenavi.class.php\u4e2d\u7684<\/p>\n<p>if(strpos($query, &#8220;act=list-&#8220;) !== false){<br \/>\n$query = preg_replace(&#8220;\/act=list\\-([0-9a-z]*)\/&#8221;,&#8221;act=list&#8221;,$_SERVER[&#8216;QUERY_STRING&#8217;]);<br \/>\n$this-&gt;hmf[&#8216;neednewpntc&#8217;] = 1 ; # newly-added<br \/>\n$query = preg_replace(&#8220;\/&amp;pntc=([0-9]*)\/&#8221;,&#8221;&#8221;, $query);<br \/>\n}<\/p>\n<p>\u7136\u540e\u5728 jdo.php\u91cc\uff0c\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u505a\u5904\u7406\uff1a<\/p>\n<p>if($_REQUEST[&#8216;pntc&#8217;] == &#8221; || $_REQUEST[&#8216;pntc&#8217;] == &#8216;0&#8217; || $navi-&gt;get(&#8216;neednewpntc&#8217;) == 1){<br \/>\n$pagenum = $gtbl-&gt;get(&#8216;pagenum&#8217;);<br \/>\n$gtbl-&gt;set(&#8216;pagenum&#8217;, 1);<br \/>\n$hm = $gtbl-&gt;getBy(&#8220;count(*) as totalcount&#8221;, $navi-&gt;getCondition($gtbl, $user));<\/p>\n<p>if($hm[0]){<br \/>\n$hm = $hm[1][0];<br \/>\n$navi-&gt;set(&#8216;totalcount&#8217;,$hm[&#8216;totalcount&#8217;]);<br \/>\n}<br \/>\n$gtbl-&gt;set(&#8216;pagenum&#8217;, $pagenum);<\/p>\n<p>}<\/p>\n<p>\u5176\u4e2d\uff0c\u00a0$navi-&gt;get(&#8216;neednewpntc&#8217;) \u7684\u5224\u65ad\u6761\u4ef6\u662f\u65b0\u589e\u7684\uff0c\u539f\u56e0\u662f\u5728\u524d\u9762\u7684 class\/pagenavi.class.php\u4e2d\u53bb\u6389\u4e86\u76f8\u5e94\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u8981\u91cd\u65b0\u7b97\u51fa\u3002 \u7531\u4e8e$navi\u5bf9\u8c61\u6b64\u65f6\u6301\u6709\u7684\u73af\u5883\u53d8\u91cf $pagenum \u548c $pagesize \u662f\u5bfc\u822a\u9875\u7684\u4e3b\u5bf9\u8c61 $obj \u7684\uff0c\u800cselect count(*) as totalcount \u7684\u7ed3\u679c\u96c6\uff0c\u53ea\u4f1a\u6709\u4e00\u6761\u8bb0\u5f55\uff0c\u56e0\u6b64\u6539\u4e4b\u524d\u4f1a\u51fa\u73b0\u4e0b\u9762\u8fd9\u6837\u7684\u67e5\u8be2SQL\uff1a<\/p>\n<p>mysql&gt; select count(*) as totalcount from tbl where &#8230;&#8230; limit 100,20<\/p>\n<p>\u8fd9\u6837\u57fa\u672c\u6709\u7ed3\u679c\u96c6\uff0c\u4f46limit\u7684\u592a\u9760\u540e\u5bfc\u81f4\u8bfb\u53d6\u4e0d\u5230\u7ed3\u679c\uff0c\u8fdb\u800c\u4e22\u5931\u4e86pntc\uff0c\u5bfc\u822a\u9875\u9762\u4e5f\u5c31\u5931\u5e38\u4e86\u3002<\/p>\n<p>\u5df2\u4fee\u6b63\u3002<\/p>\n<p><strong>2. \u521d\u59cb\u5316\u67e5\u8be2\u65f6\u91cd\u590dSQL\u95ee\u9898<\/strong><\/p>\n<p>gMIS\u91cc\uff0c\u5728inc\/webapp.class.php\u4e2d\uff0c\u5982\u679c\u6d3b\u8dc3\u5bf9\u8c61 $obj \u8fdb\u884c\u5c5e\u6027\u8bfb\u53d6\u65f6\uff0c$obj-&gt;get(&#8216;xxxx&#8217;);\u65f6\uff0c\u7cfb\u7edf\u4f1a\u5148\u8bfb\u53d6\u8fd0\u884c\u65f6\u73af\u5883\u503c\uff0c\u5982\u679c\u6ca1\u6709\u5c31\u89e6\u53d1\u53bb\u6301\u4e45\u5c42\u8bfb\u53d6\u76f8\u5e94\u6570\u636e\uff0c\u9996\u9009\u7684\u662f\u8bfb\u53d6\u6570\u636e\u5e93\u3002<\/p>\n<p>function get($field)<br \/>\n{<br \/>\nif(array_key_exists($field,$this-&gt;hmf))<br \/>\n{<br \/>\nreturn $this-&gt;hmf[$field];<br \/>\n}<br \/>\nelse if($field != &#8216;id&#8217; &amp;&amp; $field != &#8216;er&#8217;) #! Otherwise, this will cause a dead loop with ._setAll.<br \/>\n{<br \/>\nif($this-&gt;get(&#8216;er&#8217;) != 1){<br \/>\nif($this-&gt;_setAll()){<br \/>\nif(isset($this-&gt;hmf[$field])){<br \/>\nreturn $this-&gt;hmf[$field];<br \/>\n}<br \/>\nelse{<br \/>\nreturn $this-&gt;hmf[$field]=&#8221;;<br \/>\n}<br \/>\n}<br \/>\nelse{<br \/>\nreturn &#8221;;<br \/>\n}<br \/>\n}<br \/>\nelse{<br \/>\nreturn &#8221;;<br \/>\n}<br \/>\n}<br \/>\nelse{<br \/>\nreturn &#8221;;<br \/>\n}<br \/>\n}<\/p>\n<p>\u5176\u4e2d $this-&gt;get(&#8216;er&#8217;) \u7684\u5224\u65ad\u662f\u65b0\u589e\u7684\uff0c\u5982\u679c\u7b2c\u4e00\u6b21\u8bfb\u53d6\u5df2\u7ecf\u77e5\u9053\u662f\u7a7a\u8bb0\u5f55\uff0c\u6216\u8005\u65e0\u8bb0\u5f55\uff0c\u5219\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\uff0c\u4e0d\u518d\u7ee7\u7eed\u591a\u6b21\u67e5\u8be2\u540c\u4e00SQL.<\/p>\n<p>\u7c7b\u4f3c\u7684\uff0c\u8fd8\u65b0\u589e\u4e86 isset($this-&gt;hmf[$field]) \u7684\u5224\u65ad\uff0c\u8fd9\u662f\u9488\u5bf9\u67d0\u4e2a\u8fd0\u884c\u65f6\u53d8\u91cf\u53ea\u5728app\u4e2d\uff0c\u800c\u6ca1\u6709\u5728\u6301\u4e45\u5c42\u4e2d\uff0c\u8fd9\u6837\u7684\u4e5f\u4f1a\u5bfc\u81f4\u56e0\u4e3a\u4e00\u4e2a\u53d8\u91cf\u7684\u4e0d\u786e\u5b9a\u503c\uff0c\u800c\u4ea7\u751f\u7684\u591a\u6b21\u540c\u4e00SQL\u7684\u67e5\u8be2\uff0c\u52a0\u5165\u6b64\u5224\u65ad\uff0c\u5219\u53ef\u4ee5\u51cf\u7701\u6389\u8fd9\u4e9b\u4e0d\u5fc5\u8981\u7684\u5f00\u652f\u3002<\/p>\n<p><strong>3. \u4e0b\u62c9\u6846\u9009\u62e9\u9879\u7684\u52a8\u6001\u8bfb\u53d6\uff0c\u91cd\u590dSQL\u67e5\u8be2\u7684\u95ee\u9898<\/strong><\/p>\n<p>gMIS\u4e2d\u63d0\u4f9b\u4e86\u52a8\u6001\u4e0b\u62c9\u6846\u7684\u529f\u80fd\uff0c\u4e5f\u5373\u4e00\u4e2a\u4e0b\u62c9\u6846\u7684\u6570\u636e\u9009\u62e9\u9879\uff0c\u53ef\u4ee5\u52a8\u6001\u7684\u4ece\u53e6\u5916\u4e00\u4e2a\u6570\u636e\u6e90\uff08\u8868\uff09\u4e2d\u8bfb\u53d6\u3002\u8fd9\u4e3a\u7ba1\u7406\u4fe1\u606f\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u3002<\/p>\n<p>\u4e4b\u524d\u7684\u8bbe\u8ba1\u4e2d\uff0c\u5728gMIS\u7684 class\/gtbl.class.php \u4e2d\uff0c\u6bcf\u6b21\u90fd\u6765\u4e00\u4e2agetSelectOption\u5c31\u8bfb\u53d6\u4e00\u6b21\u6570\u636e\u5e93\uff0c\u6539\u8fdb\u540e\u7684\u505a\u6cd5\uff0c\u589e\u52a0\u4e86\u7f13\u5b58\uff1a<\/p>\n<p>$hmoption = array();<br \/>\nif(isset($this-&gt;hmconf[&#8216;selectoption_&#8217;.$field])){<br \/>\n$hmoption = $this-&gt;hmconf[&#8216;selectoption_&#8217;.$field];<br \/>\n}<br \/>\nelse{<br \/>\n$oldhmf = $this-&gt;hmf;<br \/>\n$this-&gt;hmf = array();<br \/>\n$this-&gt;setTbl($tbl);<br \/>\n$hm = $this-&gt;getBy(&#8220;id,$dispfield&#8221;, $arr[3]);<br \/>\nif($hm[0]){<br \/>\n$hmoption = $hm[1]; $this-&gt;hmconf[&#8216;selectoption_&#8217;.$field] = $hmoption;<br \/>\n}<br \/>\n$this-&gt;hmf = $oldhmf;<br \/>\n}<br \/>\nforeach($hmoption as $k=&gt;$rec){<br \/>\n$optionlist .= &#8220;&lt;option value=\\&#8221;&#8221;.$rec[&#8216;id&#8217;].&#8221;\\&#8221;&#8221;;<br \/>\nif($defaultval != null){<br \/>\nif($rec[&#8216;id&#8217;] == $defaultval || strpos(&#8220;,&#8221;.$defaultval.&#8221;,&#8221;, &#8220;,&#8221;.$rec[&#8216;id&#8217;].&#8221;,&#8221;) !== false){<br \/>\n$optionlist .= &#8221; selected&#8221;;<br \/>\n$selectval = $rec[$arr[2]].(isset($arr[3])?&#8221;-&#8220;.$rec[$arr[3]]:&#8221;&#8221;).&#8221; (&#8220;.$rec[&#8216;id&#8217;].&#8221;)&#8221;;<br \/>\nif($needv == 1){<br \/>\n$selectval_mul .= $rec[$arr[2]].(isset($arr[3])?&#8221;-&#8220;.$rec[$arr[3]]:&#8221;&#8221;).&#8221; (&#8220;.$rec[&#8216;id&#8217;].&#8221;),&#8221;;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n$optionlist .=&#8221;&gt;&#8221;.$rec[$arr[2]].(isset($arr[3])?&#8221;-&#8220;.$rec[$arr[3]]:&#8221;&#8221;).&#8221; (&#8220;.$rec[&#8216;id&#8217;].&#8221;)&lt;\/option&gt;\\n&#8221;;<br \/>\n}<\/p>\n<p>$hmoption\u7f13\u5b58\u5230$this-&gt;hmconf\u4e2d\u662f\u65b0\u589e\u7684\u529f\u80fd\uff0c\u8fd9\u6837\u5728\u540c\u4e00\u4e2alist\u9875\u9762\u4e2d\uff0c\u6bcf\u4e2aselect\u5b57\u6bb5\uff0c\u53ea\u8981\u4e00\u6b21SQL\u67e5\u8be2\u6570\u636e\u6e90\u5373\u53ef\u3002<\/p>\n<p>&#8212;- &#8212;-<\/p>\n<p>\u5199\u8fd9\u4e48\u591a\uff0c\u53d1\u73b0\u4e4b\u524d\u7684\u8981\u4f18\u5316\u7684\u5730\u65b9\u4e0d\u5c11\uff0c\u6539\u8fdb\u65e0\u6b62\u5883\u3002<\/p>\n<p>\u6700\u65b0\u65b0\u6ce8\u518c\u7684 -\u81ea\u7136\u57df\u540d <a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-naturedns\" target=\"_blank\">-NatureDNS\u00a0<\/a>:<\/p>\n<p><a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E4%BA%BA%E6%B0%91%E7%BD%91%E7%A0%94%E7%A9%B6%E9%99%A2&amp;f=latest\" target=\"_blank\">-\u4eba\u6c11\u7f51\u7814\u7a76\u9662<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E5%BA%A6%E5%81%87%E6%9D%91%E8%81%94%E7%9B%9F&amp;f=latest\" target=\"_blank\">-\u5ea6\u5047\u6751\u8054\u76df<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E4%B9%90%E8%A7%86%E7%BD%91&amp;f=latest\" target=\"_blank\">-\u4e50\u89c6\u7f51<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E8%98%91%E8%8F%87%E8%A1%97&amp;f=latest\" target=\"_blank\">-\u8611\u83c7\u8857<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E7%88%B1%E5%8D%A1%E6%B1%BD%E8%BD%A6&amp;f=latest\" target=\"_blank\">-\u7231\u5361\u6c7d\u8f66<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E7%99%BE%E5%BA%A6%E7%99%BE%E7%A7%91&amp;f=latest\" target=\"_blank\">-\u767e\u5ea6\u767e\u79d1<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-uc%E6%B5%8F%E8%A7%88%E5%99%A8&amp;f=latest\" target=\"_blank\">-uc\u6d4f\u89c8\u5668<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-wiki&amp;f=latest\" target=\"_blank\">-wiki<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-%E8%B1%86%E7%93%A3&amp;f=latest\" target=\"_blank\">-\u8c46\u74e3<\/a>\u00a0\u00a0\u00a0<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-1%E5%8F%B7%E5%BA%97&amp;f=latest\" target=\"_blank\">-1\u53f7\u5e97<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>gMIS \u901a\u7528\u7ba1\u7406\u4fe1\u606f\u7cfb\u7edf\uff0c\u6700\u8fd1\u8fdb\u884c\u4e86\u51e0\u4e2a\u4e3b\u8981\u66f4\u65b0\uff1a\u5220\u9664\u8bb0\u5f55\u540e\u4e22\u5931pntc\u7684\u5bfc\u822a &hellip; <a href=\"https:\/\/ufqi.com\/blog\/gmis-updates-20140417\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41,6,2],"tags":[],"_links":{"self":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/432"}],"collection":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":7,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":435,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions\/435"}],"wp:attachment":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}