{"id":1209,"date":"2016-05-02T10:02:46","date_gmt":"2016-05-02T02:02:46","guid":{"rendered":"http:\/\/ufqi.com\/blog\/?p=1209"},"modified":"2016-05-02T10:25:12","modified_gmt":"2016-05-02T02:25:12","slug":"gmis-installation-and-mysqli","status":"publish","type":"post","link":"https:\/\/ufqi.com\/blog\/gmis-installation-and-mysqli\/","title":{"rendered":"-gMIS\/-GWA2\u66f4\u65b0\uff1a\u81ea\u52a8\u5b89\u88c5\u7a0b\u5e8f\u548cMySQLi"},"content":{"rendered":"<p>\u4e94\u4e00\u671f\u95f4\uff0c\u4eac\u6d25\u5180\u53ef\u6076\u7684\u96fe\u973e\u5708\u4f4f\u4e86\u5954\u5411\u539f\u91ce\u7684\u5fc3\uff0c\u521a\u597d\u62bd\u7a7a\u5b8c\u5584\u4e86\u9488\u5bf9 -gMIS \u548c -GWA2 \u7684\u81ea\u52a8\u5b89\u88c5\u7a0b\u5e8f\uff0c\u540c\u65f6\u66f4\u65b0\u4e86inc\/mysql.class\u4e2d\u5bf9 MySQLi\u7684\u652f\u6301\uff0c\u989d\u5916\u7684\u6536\u83b7\uff0c\u5728\u5236\u4f5c\u81ea\u52a8\u5b89\u88c5\u7a0b\u5e8f\u65f6\uff0c\u53d1\u73b0\u4e00\u79cd\u751f\u6210 HTML Form\u7684\u65b9\u6cd5\uff0c\u5185\u5bb9\u9644\u540e\u9762\u3002<\/p>\n<p><strong>1. \u81ea\u52a8\u5728\u7ebf\u5b89\u88c5\u7a0b\u5e8finstall.php<br \/>\n<\/strong>gMIS\u3001GWA2 \u63d0\u4f9b\u4e86\u81ea\u52a8\u5728\u7ebf\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5c06 install.php \u811a\u672c\u7a0b\u5e8f\u4e0b\u8f7d\u5e76\u653e\u7f6e\u5230\u76ee\u6807\u5b89\u88c5\u76ee\u5f55\u4e0b\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u8be5\u811a\u672c\uff0c\u8fd0\u884c install.php \u5373\u542f\u52a8\u5b89\u88c5\u7a0b\u5e8f\u3002<\/p>\n<p><a href=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gmis-install-start-201604.jpg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1210\" alt=\"gmis-install-start-201604\" src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gmis-install-start-201604.jpg\" width=\"865\" height=\"444\" srcset=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gmis-install-start-201604.jpg 865w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gmis-install-start-201604-300x153.jpg 300w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/a><\/p>\n<p>\u5b89\u88c5\u7a0b\u5e8f\u9996\u5148\u68c0\u67e5\u5f53\u524d\u5b89\u88c5\u73af\u5883\uff0c\u76ee\u524d\u7684\u53ef\u8bfb\u53ca\u53ef\u5199\uff1b\u7136\u540e\u8fdb\u884c\u6e90\u4ee3\u7801\u7684\u4e0b\u8f7d\uff0c\u6e90\u4ee3\u7801\u4ece \u2013Github-Wadelau \u4e0a\u8bfb\u53d6\uff0c\u4e0b\u8f7d\u5230Zip\u538b\u7f29\u5305\u540e\uff0c\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u7684\u76f8\u5173\u7a0b\u5e8f\u8fdb\u884c\u89e3\u538b\uff0c\u7136\u540e\u8fdb\u884c\u6570\u636e\u5e93\u7684\u914d\u7f6e\u3001\u6837\u4f8b\u6a21\u5757Hello\u7684\u521d\u59cb\u5316\u8bbe\u7f6e\u3002<\/p>\n<p>\u5b89\u88c5\u7a0b\u5e8f\u6700\u540e\u4f1a\u5f15\u5bfc\u5230\u9879\u76ee\u7684\u521d\u59cb\u9875\u9762\u3002install.php \u8be6\u7ec6\u6784\u6210\u90e8\u4ef6\u53ca\u6784\u6210\u8bf7\u53c2\u8003\u4e0b\u56fe\u3002<\/p>\n<p><a href=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gMIS\u81ea\u52a9\u5b89\u88c5.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1211\" alt=\"-gMIS\u81ea\u52a9\u5b89\u88c5\" src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gMIS\u81ea\u52a9\u5b89\u88c5.png\" width=\"877\" height=\"576\" srcset=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gMIS\u81ea\u52a9\u5b89\u88c5.png 877w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gMIS\u81ea\u52a9\u5b89\u88c5-300x197.png 300w\" sizes=\"(max-width: 877px) 100vw, 877px\" \/><\/a><\/p>\n<p>Figure 7 auto installation in -gMIS<\/p>\n<p>\u5b89\u88c5\u7a0b\u5e8f\u4f9d\u8d56\u64cd\u4f5c\u7cfb\u7edf\u6240\u63d0\u4f9b\u7684\u4e00\u4e9b\u64cd\u4f5c\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li>rm<\/li>\n<li>mv<\/li>\n<li>wget<\/li>\n<li>unzip<\/li>\n<\/ul>\n<p><strong>2. MySQLi\u7684\u652f\u6301<\/strong><br \/>\n\u5728\u8f83\u65b0\u7684 -PHP \u73af\u5883\u4e2d\uff0c\u8fd0\u884c mysql_connect \u65f6\uff0c\u4f1a\u62a5\u9519\uff1a<br \/>\nDeprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in xxxx file.<\/p>\n<p>MySQLi\u540d\u79f0\u662f\u53d6\u81eaMySQL Improved\u7684\u7f29\u5199\uff0c\u5b83\u662f<a title=\"MySQL\" href=\"https:\/\/zh.wikipedia.org\/wiki\/MySQL\">MySQL<\/a>\u9488\u5bf9<a title=\"PHP\" href=\"https:\/\/zh.wikipedia.org\/wiki\/PHP\">PHP<\/a>\u6240\u8bbe\u8ba1\u7684\u4e00\u4e2a<a title=\"\u63d2\u4ef6\" href=\"https:\/\/zh.wikipedia.org\/wiki\/%E6%8F%92%E4%BB%B6\">\u6269\u5145\u6a21\u7ec4<\/a>\u3002\u867d\u7136<a title=\"PHP\" href=\"https:\/\/zh.wikipedia.org\/wiki\/PHP\">PHP<\/a>\u539f\u672c\u5c31\u6709\u80fd\u591f\u5b58\u53d6MySQL\u7684<a title=\"\u51fd\u5f0f\u5e93\" href=\"https:\/\/zh.wikipedia.org\/wiki\/%E5%87%BD%E5%BC%8F%E5%BA%AB\">\u51fd\u5f0f\u5e93<\/a>\uff0c\u4f46\u662f\u5728MySQL 4.1.3\u7248\u4e4b\u540e\uff0cPHP\u5b98\u65b9\u5f3a\u70c8\u63a8\u8350\u4f7f\u7528MySQLi\u3002<\/p>\n<p><em>mysqli<\/em>\u6269\u5c55\uff0c\u6211\u4eec\u6709\u65f6\u79f0\u4e4b\u4e3aMySQL<em>\u589e\u5f3a<\/em>\u6269\u5c55\uff0c\u53ef\u4ee5\u7528\u4e8e\u4f7f\u7528 MySQL4.1.3\u6216\u66f4\u65b0\u7248\u672c\u4e2d\u65b0\u7684\u9ad8\u7ea7\u7279\u6027\u3002<em>mysqli<\/em>\u6269\u5c55\u5728PHP 5\u53ca\u4ee5\u540e\u7248\u672c\u4e2d\u5305\u542b\u3002<em>mysqli<\/em>\u6269\u5c55\u6709\u4e00\u7cfb\u5217\u7684\u4f18\u52bf\uff0c\u76f8\u5bf9\u4e8e<em>mysql<\/em>\u6269\u5c55\u7684\u63d0\u5347\u4e3b\u8981\u6709\uff1a<\/p>\n<ul>\n<li>\u9762\u5411\u5bf9\u8c61\u63a5\u53e3<\/li>\n<li>prepared\u8bed\u53e5\u652f\u6301\uff08\u8bd1\u6ce8\uff1a\u5173\u4e8eprepare\u8bf7\u53c2\u9605mysql\u76f8\u5173\u6587\u6863\uff09<\/li>\n<li>\u591a\u8bed\u53e5\u6267\u884c\u652f\u6301<\/li>\n<li>\u4e8b\u52a1\u652f\u6301<\/li>\n<li>\u589e\u5f3a\u7684\u8c03\u8bd5\u80fd\u529b<\/li>\n<li>\u5d4c\u5165\u5f0f\u670d\u52a1\u652f\u6301<\/li>\n<\/ul>\n<p>\u5728\u63d0\u4f9b\u4e86\u9762\u5411\u5bf9\u8c61\u63a5\u53e3\u7684\u540c\u65f6\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9762\u5411\u8fc7\u7a0b\u7684\u63a5\u53e3\u3002<em>mysqli<\/em>\u6269\u5c55\u662f\u4f7f\u7528PHP\u6269\u5c55\u6846\u67b6\u6784\u5efa\u7684\uff0c\u5b83\u7684\u6e90\u4ee3\u7801\u5728PHP\u6e90\u7801\u76ee\u5f55\u4e0b\u7684<var>ext\/mysqli<\/var>\u4e2d\u3002<\/p>\n<p>\u4e0ePDO \uff08PHP \u6570\u636e\u5bf9\u8c61\uff09\u4e0d\u540c\uff0c\u540e\u8005\u63d0\u4f9b\u4e86\u4e00\u4e2a\u00a0<em>\u6570\u636e\u8bbf\u95ee<\/em>\u00a0\u62bd\u8c61\u5c42\uff0c\u8fd9\u610f\u5473\u7740\uff0c\u4e0d\u7ba1\u4f7f\u7528\u54ea\u79cd\u6570\u636e\u5e93\uff0c\u90fd\u53ef\u4ee5\u7528\u76f8\u540c\u7684\u51fd\u6570\uff08\u65b9\u6cd5\uff09\u6765\u67e5\u8be2\u548c\u83b7\u53d6\u6570\u636e\u3002 PDO \u4e0d\u63d0\u4f9b\u00a0<em>\u6570\u636e\u5e93<\/em>\u00a0\u62bd\u8c61\u5c42\uff1b\u5b83\u4e0d\u4f1a\u91cd\u5199 SQL\uff0c\u4e5f\u4e0d\u4f1a\u6a21\u62df\u7f3a\u5931\u7684\u7279\u6027\u3002\u5982\u679c\u9700\u8981\u7684\u8bdd\uff0c\u5e94\u8be5\u4f7f\u7528\u4e00\u4e2a\u6210\u719f\u7684\u62bd\u8c61\u5c42\u3002<\/p>\n<p>\u7531\u4e8e\u5728 -GWA2 \u7684\u8bbe\u8ba1\u4e2d\uff0c\u5df2\u7ecf\u5c06\u5b58\u50a8\u9a71\u52a8\u5355\u72ec\u9694\u79bb\u5f00\u6765\uff0c\u5982\u6570\u636e\u5e93\u7684\u9a71\u52a8\uff0c\u7ecf\u7531 inc\/dba.class \u6765\u5b9e\u73b0\uff0cMySQL\u7684\u8fde\u63a5\uff0c\u9ed8\u8ba4\u4f7f\u7528 inc\/mysql.class \u6765\u5b9e\u73b0\uff0c\u56e0\u6b64\u6539\u8fdb\u67b6\u6784\u5bf9MySQLi\u7684\u652f\u6301\uff0c\u53ea\u8981\u4fee\u6539\u6570\u636e\u5e93\u8fde\u63a5\u9a71\u52a8\uff0cinc\/mysql.class\u6587\u4ef6\u4e2d\u76f8\u5e94\u7684\u6587\u4ef6\u5373\u53ef\u3002<\/p>\n<p>\u540c\u65f6\uff0c\u8003\u8651\u524d\u5411\u517c\u5bb9\u6ca1\u6709 MySQLi \u7684\u8fd0\u884c\u73af\u5883\uff0c\u9700\u8981\u5728\u8fc7\u5ea6\u9636\u6bb5\u5bf9MySQL\u7684\u8fd0\u884c\u6a21\u5f0f\u8fdb\u884c\u5224\u65ad\uff0c\u4e5f\u5373\u4f18\u5148\u5224\u65ad\u5f53\u524d\u73af\u5883\u662f\u5426\u652f\u6301 MySQLi &#8212; \u5982\u679c\u652f\u6301\uff0c\u5219\u542f\u7528\u529f\u80fd\u66f4\u5f3a\u5927\u7684 MySQLi \u589e\u5f3a\u6269\u5c55, \u5982\u679c\u4e0d\u652f\u6301\uff0c\u5219\u4ecd\u56de\u5f52\u4f7f\u7528\u65e7\u5f0f\u7684 MySQL \u6269\u5c55\u3002<\/p>\n<p>\/\/-<\/p>\n<p>function _initconnection(){<br \/>\nif ($this-&gt;m_link==0){<br \/>\n$real_host = $this-&gt;m_host.&#8221;:&#8221;.$this-&gt;m_port;<br \/>\n\/\/echo $real_host,$this-&gt;m_user,$this-&gt;m_password;<br \/>\n$this-&gt;mode = function_exists(&#8216;mysqli_connect&#8217;) ? &#8216;mysqli&#8217; : &#8216;mysql&#8217;;<br \/>\nif($this-&gt;mode == &#8216;mysqli&#8217;){<br \/>\n$this-&gt;m_link = new mysqli($this-&gt;m_host, $this-&gt;m_user, $this-&gt;m_password, $this-&gt;m_name, $this-&gt;m_port);<br \/>\n}<br \/>\nelse{<br \/>\n$this-&gt;m_link = mysql_connect($real_host,$this-&gt;m_user,$this-&gt;m_password) or die($this-&gt;Err(&#8220;mysql connect&#8221;));<br \/>\n}<br \/>\n\/\/echo $this-&gt;Err();<br \/>\n\/\/echo &#8220;[&#8220;.$this-&gt;m_link.&#8221;]&#8221;;<br \/>\nif ($this-&gt;mode == &#8216;mysql&#8217; &amp;&amp; &#8220;&#8221; != $this-&gt;m_name){<br \/>\nmysql_select_db($this-&gt;m_name, $this-&gt;m_link) or die($this-&gt;Err(&#8220;use &#8220;.$this-&gt;m_name));<br \/>\n}<br \/>\nif(get_magic_quotes_gpc()){ $this-&gt;ismagicquote = 1; }<br \/>\n}<br \/>\n}<\/p>\n<p>\u5728\u53d1\u8d77\u8fde\u63a5\u4e4b\u540e\uff0c\u5176\u4ed6\u76f8\u5173\u7684\u51fd\u6570\u8c03\u7528\u6216\u8005\u5bf9\u8c61\u53ca\u65b9\u6cd5\u7684\u4f7f\u7528\uff0c\u4e5f\u8981\u6839\u636e\u6b64\u5904\u7684 $this-&gt;mode \u505a\u76f8\u5e94\u7684\u8c03\u6574\u3002<\/p>\n<p><strong>3. \u4e00\u79cd\u5feb\u6377\u7684 HTML Form \u751f\u6210\u65b9\u6cd5<\/strong><br \/>\nHTML Form\u5728 WebApp \u4e2d\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u662f\u8fdb\u884c\u6570\u636e\u4ea4\u4e92\u7684\u57fa\u672c\u5f62\u5f0f\u4e4b\u4e00\uff0c\u6784\u9020\u4e00\u4e2aHTML Form\u6709\u5f88\u591a\u79cd\u65b9\u6cd5\uff0c\u5982\u4e0b\u662f\u5728PHP\u4e2d\uff0c\u5feb\u901f\u751f\u6210\u4e00\u4e2aForm\u8868\u5355\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002<\/p>\n<p># create a form output<br \/>\nfunction xForm($nextact, $fields, $isfile=0){<br \/>\n$rd = rand(100, 99999);<br \/>\n$form_header = &#8220;\\n&lt;br\/&gt;&lt;div id=&#8217;formdiv&#8221;.$rd.&#8221;&#8216;&gt;&lt;form name=\\&#8221;myform$rd\\&#8221; id=\\&#8221;myform$rd\\&#8221; action=\\&#8221;&#8221;.$nextact.&#8221;\\&#8221; method=\\&#8221;post\\&#8221; &#8220;;<br \/>\nif($isfile == 1){<br \/>\n$form_header .= &#8221; enctype=\\&#8221;multipart\/form-data\\&#8221;&#8221;;<br \/>\n}<br \/>\nelse{<br \/>\n$form_header .= &#8221; enctype=\\&#8221;application\/x-www-form-urlencoded\\&#8221;&#8221;;<br \/>\n}<br \/>\n$form_header .= &#8220;&gt;&#8221;;<br \/>\n$form_footer = &#8220;&lt;br\/&gt;&lt;br\/&gt;&lt;input type=&#8217;submit&#8217; name=&#8217;mysubmit&#8217; value=&#8217;\u786e\u5b9a&amp;\u4e0b\u4e00\u6b65&#8217; \/&gt;&#8221;;<br \/>\n$form_footer .= &#8220;&amp;nbsp;&amp;nbsp;&lt;input name=&#8217;myback&#8217; type=&#8217;button&#8217; value=&#8217;\u53d6\u6d88&amp;\u8fd4\u56de&#8217; onclick=&#8217;javascript:window.history.back(-1);&#8217; \/&gt;&#8221;;<br \/>\n$form_footer .= &#8220;&lt;\/form&gt;&lt;\/div&gt;&#8221;;<\/p>\n<p>$form_field = &#8221;;<br \/>\n$xform = &#8221;;<br \/>\nif(is_array($fields)){<br \/>\nforeach($fields as $k=&gt;$v){<br \/>\n$dispname = &#8221;;<br \/>\n$form_field = &#8216;&lt;input name=&#8221;&#8216;.$k.'&#8221; id=&#8221;&#8216;.$k.'&#8221;&#8216;;<br \/>\nif(is_array($v)){<br \/>\nforeach($v as $k1=&gt;$v1){<br \/>\nif($k1 == &#8216;dispname&#8217;){ $dispname = $v1; }<br \/>\nelse{ $form_field .= &#8221; $k1=&#8217;$v1&#8242;&#8221;; }<br \/>\n}<br \/>\n}<br \/>\nelse{<br \/>\nprint __FILE__.&#8221;: illegal setting. 1604161129.&#8221;;<br \/>\n}<br \/>\n$form_field = &#8220;\\n&lt;br\/&gt;&lt;br\/&gt;&#8221;.$dispname.&#8221;: &#8220;.$form_field.&#8221; \/&gt;&#8221;;<br \/>\n$xform .= $form_field;<br \/>\n}<br \/>\n}<br \/>\nelse if($fields == null){<br \/>\n# no extra field.<br \/>\n}<br \/>\nelse{<br \/>\nprint __FILE__.&#8221;: illegal setting. 1604161130.&#8221;;<br \/>\n}<\/p>\n<p>#return $form_header.$form_field.$form_footer;<br \/>\nreturn $form_header.$xform.$form_footer;<\/p>\n<p>}<\/p>\n<p>\u4f7f\u7528\u8303\u4f8b\uff1a<\/p>\n<p>$out .= xForm($file.&#8217;&amp;step=dolicense&#8217;, array(&#8216;hasagree&#8217;=&gt;array(&#8216;type&#8217;=&gt;&#8217;checkbox&#8217;, &#8216;dispname&#8217;=&gt;&#8217;\u6211\u5df2\u9605\u8bfb\u4f7f\u7528\u534f\u8bae\u5e76\u540c\u610f&#8217;)));<\/p>\n<p>\u5c06\u4f1a\u751f\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\uff0c\u8fd8\u6709\u4e00\u4e2a\u586b\u5199\u5b57\u6bb5\u7684HTML Form\u8868\u5355\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e94\u4e00\u671f\u95f4\uff0c\u4eac\u6d25\u5180\u53ef\u6076\u7684\u96fe\u973e\u5708\u4f4f\u4e86\u5954\u5411\u539f\u91ce\u7684\u5fc3\uff0c\u521a\u597d\u62bd\u7a7a\u5b8c\u5584\u4e86\u9488\u5bf9 -gMIS \u548c &hellip; <a href=\"https:\/\/ufqi.com\/blog\/gmis-installation-and-mysqli\/\">\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,42,6,2],"tags":[20,86,131,132],"_links":{"self":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1209"}],"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=1209"}],"version-history":[{"count":5,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1209\/revisions"}],"predecessor-version":[{"id":1213,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1209\/revisions\/1213"}],"wp:attachment":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media?parent=1209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/categories?post=1209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/tags?post=1209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}