{"id":30158,"date":"2024-11-25T13:17:51","date_gmt":"2024-11-25T05:17:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30158\/"},"modified":"2024-11-25T13:17:51","modified_gmt":"2024-11-25T05:17:51","slug":"%e5%be%ae%e4%bf%a1%e5%bc%80%e5%8f%91%e4%b9%8b%e6%95%b0%e6%8d%ae%e5%ba%93%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30158\/","title":{"rendered":"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5f00\u53d1 \u6570\u636e\u5e93\u64cd\u4f5c\u7684\u76f8\u5173\u8d44\u6599,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/p>\n<p><strong>\u4e00\u3001\u7b80\u4ecb<\/strong><\/p>\n<p>\u524d\u9762\u8bb2\u89e3\u7684\u529f\u80fd\u5f00\u53d1\u90fd\u662f\u7b80\u5355\u7684\u8c03\u7528 \u5b8c\u6210\u7684\uff0c\u6ca1\u6709\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\u3002\u5728\u63a5\u4e0b\u6765\u7684\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5230\u6570\u636e\u5e93\uff0c\u6240\u4ee5\u5728\u8fd9\u4e00\u7bc7\u4e2d\uff0c\u5c06\u5bf9 \u6570\u636e\u5e93\u7684\u64cd\u4f5c\u505a\u4e00\u4e0b\u7b80\u5355\u7684\u4ecb\u7ecd\uff0c\u4ee5\u4f9b\u8bfb\u8005\u53c2\u8003\u3002<\/p>\n<p><strong>\u4e8c\u3001\u601d\u8def\u5206\u6790<\/strong><\/p>\n<p>\u767e\u5ea6\u5f00\u53d1\u8005\u4e2d\u5fc3\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4e91\u6570\u636e\u5e93\uff08\u5305\u62ecMySQL, , \uff09\uff0c\u5728\u8fd9\u4e00\u8282\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9\u5927\u5bb6\u6bd4\u8f83\u719f\u6089\u7684MySQL \u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\u6f14\u793a\uff0c\u5b9e\u73b0\u5fae\u4fe1\u4e0e\u6570\u636e\u5e93\u7684\u4ea4\u4e92\u3002<\/p>\n<p>\u5728BAE\u5e94\u7528\u4e2d\u4f7f\u7528\u4e91\u6570\u636e\u5e93\u5341\u5206\u7b80\u5355\uff0c\u6570\u636e\u5e93\u5217\u8868\u4e2d\u7684\u540d\u79f0\u5373\u662f\u65f6\u7684dbname\u3002\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u8fde\u63a5\u5730\u5740\u548c\u7aef\u53e3\u5728\u5e94\u7528\u4e2d\u901a\u8fc7\u73af\u5883\u53d6\u51fa\u3002<\/p>\n<p>\u53ef\u4f7f\u7528\u6807\u51c6\u7684PHP Mysql \u6216PHP Mysqli \u6269\u5c55\u8bbf\u95ee\u6570\u636e\u5e93\uff0cBAE\u7684PHP\u4e2d\u5df2\u63d0\u4f9b\u8fd9\u4e24\u4e2a\u6269\u5c55\uff0c\u5e94\u7528\u53ef\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n<p><strong>\u4e09\u3001\u521b\u5efaBAE <\/strong><\/p>\n<p>3.1 \u767b\u9646\u767e\u5ea6\u5f00\u53d1\u8005\u4e2d\u5fc3 -&gt; \u7ba1\u7406\u4e2d\u5fc3 -&gt; \u9009\u62e9\u5e94\u7528 -&gt; \u4e91\u73af\u5883 -&gt; \u670d\u52a1\u7ba1\u7406 -&gt; MySQL(\u4e91\u6570\u636e\u5e93) -&gt; <\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/8f919c247a9cec2a11b2b43dd52b5ae8-0.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe\" \/><\/p>\n<p>3.2 \u521b\u5efa\u6570\u636e\u5e93<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/ec1d2aaf93a5079367dc2b05a160e4b3-1.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe1\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe1\" \/><\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u6bcf\u4e2a\u5e94\u7528\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e93\u4eab\u53d71G\u514d\u8d39\u914d\u989d\uff0c\u5176\u4f59\u6570\u636e\u5e93\u5747\u4e0d\u4eab\u53d7\u514d\u8d39\u914d\u989d\u4f18\u60e0\u3002\u53ea\u6709\u5c06\u5df2\u4f7f\u7528\u514d\u8d39\u914d\u989d\u7684\u6570\u636e\u5e93\uff0c\u624d\u80fd\u518d\u6b21\u4f7f\u7528\u6b64\u9879\u4f18\u60e0\u3002<\/p>\n<p>3.3 \u521b\u5efa\u6210\u529f<\/p>\n<p>\u5728\u8fd9\u91cc\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5e93\u7684\u540d\u79f0\uff0c\u4e5f\u5c31\u662fdbname\uff0c\u540e\u9762\u4f1a\u4f7f\u7528\u5230\u3002<\/p>\n<p>\u70b9\u51fb \u201cphpMyadmin\u201d \u8bbf\u95ee\u6570\u636e\u5e93\u3002<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/7423ba5b755bcb6cc505f76ba368a758-2.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe2\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe2\" \/><\/p>\n<p>3.4 phpMyadmin\u754c\u9762<\/p>\n<p>\u65b0\u5efa\u6570\u636e\u8868\uff0c\u8f93\u5165\u8868\u540d\u53ca\u5b57\u6bb5\u6570\uff0c\u70b9\u51fb \u201c\u6267\u884c\u201d \u521b\u5efa\u8868\u3002<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/7423ba5b755bcb6cc505f76ba368a758-3.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe3\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe3\" \/><\/p>\n<p>3.5 \u521b\u5efa\u8868<\/p>\n<p>\u8f93\u5165\u5b57\u6bb5\u540d\u53ca\u5b57\u6bb5\u7c7b\u578b\uff0c\u8f93\u5165\u5b8c\u6bd5\u540e\uff0c\u70b9\u51fb\u4e0b\u9762\u7684\u201c\u4fdd\u5b58\u201d\uff0c\u5b8c\u6210\u8868\u7684\u521b\u5efa\u3002<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/96712c7139d5bb5b4d5aed124842b390-4.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe4\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe4\" \/><\/p>\n<p>3.6 \u521b\u5efa\u5b8c\u6210<\/p>\n<p>\u4fee\u6539id \u5b57\u6bb5\u4e3a\u4e3b\u952e\u5e76\u6dfb\u52a0AUTO_INCREMENT\uff1b\u4fee\u6539from_user \u5b57\u6bb5\u4e3a\u552f\u4e00\uff08UNIQUE\uff09\uff0c\u5b8c\u6210\u8868\u7684\u4fee\u6539\u3002<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/96712c7139d5bb5b4d5aed124842b390-5.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe5\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe5\" \/><\/p>\n<p>\u5efa\u8868\u64cd\u4f5c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\u5b8c\u6210\uff1a<\/p>\n<pre>CREATE&nbsp;TABLE&nbsp;IF&nbsp;NOT&nbsp;EXISTS&nbsp;`test_mysql`\r\n&nbsp;(&nbsp;`id`&nbsp;int(11)&nbsp;NOT&nbsp;NULL&nbsp;AUTO_INCREMENT,\r\n&nbsp;`from_user`&nbsp;varchar(40)&nbsp;DEFAULT&nbsp;NULL,&nbsp;\r\n`account`&nbsp;varchar(40)&nbsp;DEFAULT&nbsp;NULL,&nbsp;\r\n`password`&nbsp;varchar(40)&nbsp;DEFAULT&nbsp;NULL,\r\n&nbsp;`update_time`&nbsp;datetime&nbsp;DEFAULT&nbsp;NULL,&nbsp;PRIMARY&nbsp;KEY&nbsp;(`id`),&nbsp;UNIQUE&nbsp;KEY&nbsp;\r\n`from_user`&nbsp;(`from_user`));<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>phpMyAdmin \u64cd\u4f5c<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/5c3b82b2376a359349e0d4ff4ac63c09-6.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe6\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe6\" \/><\/p>\n<p>\u6570\u636e\u5e93\u53ca\u6570\u636e\u8868\u7684\u521b\u5efa\u5230\u6b64\u7ed3\u675f\uff0c\u4e0b\u9762\u5c06\u7f16\u5199\u4ee3\u7801\u5bf9\u6570\u636e\u5e93\u53ca\u6570\u636e\u8868\u7684\u4f7f\u7528\u505a\u8be6\u7ec6\u8bb2\u89e3\u3002<\/p>\n<p><strong>\u56db\u3001\u5b98\u65b9\u793a\u4f8b\uff08PHP MySQL\uff09<\/strong><\/p>\n<p>BAE \u5b98\u65b9\u63d0\u4f9b\u7684demo\uff08PHP MySQL\uff09\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<p>mysql\/basic.php \u6587\u4ef6\u5185\u5bb9<\/p>\n<pre>&lt;!--?php\r\n \r\nrequire_once &#039;includes\/configure.php&#039;;\r\n \r\nclass MySQLi_BAE{\r\n \r\n  private $mysqli;\r\n  private $host;\r\n  private $user;\r\n  private $password;\r\n  private $port;\r\n  private $database;\r\n \r\n  \/\/\u5728\u7c7b\u4e4b\u5916\u8bbf\u95ee\u79c1\u6709\u53d8\u91cf\u65f6\u4f7f\u7528\r\n  function get($property_name){\r\n    if(isset($this---&gt;$property_name)){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return($this-&amp;gt;$property_name);\r\n&nbsp;&nbsp;&nbsp;&nbsp;}else{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(NULL);\r\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\r\n&nbsp;&nbsp;}\r\n&nbsp;\r\n&nbsp;&nbsp;function&nbsp;set($property_name,&nbsp;$value){\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;$property_name=$value;\r\n&nbsp;&nbsp;}\r\n&nbsp;\r\n&nbsp;&nbsp;function&nbsp;construct(){\r\n&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\/*\u4ece\u5e73\u53f0\u83b7\u53d6\u67e5\u8be2\u8981\u8fde\u63a5\u7684\u6570\u636e\u5e93\u540d\u79f0*\/\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;database&nbsp;=&nbsp;MYSQLNAME;\r\n&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\/*\u4ece\u73af\u5883\u53d8\u91cf\u91cc\u53d6\u51fa\u6570\u636e\u5e93\u8fde\u63a5\u9700\u8981\u7684\u53c2\u6570*\/\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;host&nbsp;=&nbsp;getenv('HTTP_BAE_ENV_ADDR_SQL_IP');\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;user&nbsp;=&nbsp;getenv('HTTP_BAE_ENV_AK');\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;password&nbsp;=&nbsp;getenv('HTTP_BAE_ENV_SK');\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;port&nbsp;=&nbsp;getenv('HTTP_BAE_ENV_ADDR_SQL_PORT');\r\n&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;mysqli&nbsp;=&nbsp;new&nbsp;mysqli($this-&amp;gt;host,&nbsp;$this-&amp;gt;user,&nbsp;$this-&amp;gt;password,&nbsp;$this-&amp;gt;database,&nbsp;$this-&amp;gt;port);\r\n&nbsp;&nbsp;&nbsp;&nbsp;if($this-&amp;gt;mysqli-&amp;gt;connect_error){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(\"Connect&nbsp;Server&nbsp;Failed:\".$this-&amp;gt;mysqli-&amp;gt;error);\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;mysqli-&amp;gt;query(\"set&nbsp;names&nbsp;utf8\");\r\n&nbsp;&nbsp;}\r\n&nbsp;\r\n&nbsp;&nbsp;\/\/dql&nbsp;statement\r\n&nbsp;&nbsp;function&nbsp;execute_dql($query){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;$res&nbsp;=&nbsp;$this-&amp;gt;mysqli-&amp;gt;query($query)&nbsp;or&nbsp;die(\"\u64cd\u4f5c\u5931\u8d25\".$this-&amp;gt;mysqli-&amp;gt;error);\r\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$res;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/$this-&amp;gt;mysqli-&amp;gt;close();\r\n&nbsp;&nbsp;}\r\n&nbsp;\r\n&nbsp;&nbsp;\/\/dml&nbsp;statement\r\n&nbsp;&nbsp;function&nbsp;execute_dml($query){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;$res&nbsp;=&nbsp;$this-&amp;gt;mysqli-&amp;gt;query($query)&nbsp;or&nbsp;die(\"\u64cd\u4f5c\u5931\u8d25\".$this-&amp;gt;mysqli-&amp;gt;error);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;if(!$res){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;\/\/\u5931\u8d25\r\n&nbsp;&nbsp;&nbsp;&nbsp;}else{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($this-&amp;gt;mysqli-&amp;gt;affected_rows&nbsp;&amp;gt;&nbsp;0){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;1;\/\/\u6267\u884c\u6210\u529f\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;2;\/\/\u6ca1\u6709\u884c\u53d7\u5f71\u54cd\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/$this-&amp;gt;mysqli-&amp;gt;close();\r\n&nbsp;&nbsp;}\r\n}\r\n?&amp;gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4e5d\u3001\u6d4b\u8bd5\u7c7b\u7684\u4f7f\u7528<\/strong><\/p>\n<p>9.1 \u6d4b\u8bd5DML\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;!--?php\r\n \r\nrequire_once \"MySQLi_BAE.class.php\";\r\n \r\n$mysqli_BAE=new MySQLi_BAE();\r\n \r\n \r\n\/\/**************dml*******************\r\n$sql=\"insert into test_mysql (from_user, account, password, update_time) values(&#039;David&#039;,&#039;860510&#039;, &#039;abcabc&#039;, &#039;2013-09-27 17:14:28&#039;)\";\r\n \r\n\/\/$sql=\"update test_mysql set account = 860512 where account = 860510\";\r\n \r\n\/\/$sql=\"delete from test_mysql where account = 860512\";\r\n \r\n$res=$mysqli_BAE---&gt;execute_dml($sql);\r\n&nbsp;\r\nif($res==0){\r\n&nbsp;&nbsp;echo&nbsp;\"\u6267\u884c\u5931\u8d25\";\r\n}elseif($res==1){\r\n&nbsp;&nbsp;echo&nbsp;\"\u6267\u884c\u6210\u529f\";\r\n}else{\r\n&nbsp;&nbsp;echo&nbsp;\"\u6ca1\u6709\u884c\u6570\u5f71\u54cd\";\r\n}\r\n?&amp;gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/bcf1fcc0aa1655c3eb83b6a59bc37c5c-23.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe7\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe7\" \/><\/p>\n<p>9.2 \u6d4b\u8bd5DQL\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;!--?php\r\n \r\nrequire_once \"MySQLi_BAE.class.php\";\r\n \r\n$mysqli_BAE=new MySQLi_BAE();\r\n \r\n\/\/**************dql******************\r\n$sql=\"select * from test_mysql\";\r\n \r\n$res=$mysqli_BAE---&gt;execute_dql($sql);\r\n&nbsp;\r\nwhile($row=$res-&amp;gt;fetch_row()){\r\n&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;foreach($row&nbsp;as&nbsp;$key=&amp;gt;$val){\r\n&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;\"$val--\";\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;echo&nbsp;'\r\n';\r\n}\r\n&nbsp;\r\n$res-&amp;gt;free();\r\n?&amp;gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/bcf1fcc0aa1655c3eb83b6a59bc37c5c-24.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe8\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe8\" \/><\/p>\n<p><strong>\u5341\u3001\u5b9e\u73b0\u4e0e\u5fae\u4fe1\u7684\u4ea4\u4e92\uff08Mysqli \u6269\u5c55\uff09<\/strong><\/p>\n<p>10.1 \u524d\u7f6e\u64cd\u4f5c<\/p>\n<p>A. \u5f15\u5165MySQLi_BAE.class.php \u6587\u4ef6<\/p>\n<p>\/\/\u5f15\u5165\u6570\u636e\u5e93\u51fd\u6570\u6587\u4ef6require_once &#8220;MySQLi_BAE.class.php&#8221;;<\/p>\n<p>B. \u5b9e\u4f8b\u5316<\/p>\n<p>public function construct(){ $this-&gt;mysqli_BAE=new MySQLi_BAE();}<\/p>\n<p>10.2 \u6d4b\u8bd5\u63d2\u5165\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>$insert_sql=&#8221;INSERT INTO test_mysql(from_user, account, password, update_time) VALUES(&#8216;$fromUsername&#8217;,<\/p>\n<p>&#8216;$keywords[1]&#8217;,&#8217;$keywords[2]&#8217;,&#8217;$nowtime&#8217;)&#8221;;$res = $this-&gt;mysqli_BAE-&gt;execute_dml($insert_sql);<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/5bbedb55d2e57da63067da42130e3cca-25.png\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe9\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe9\" \/><\/p>\n<p>10.3 \u6d4b\u8bd5\u67e5\u8be2\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>$select_sql=&#8221;SELECT * FROM test_mysql WHERE from_user=&#8217;$fromUsername'&#8221;;<\/p>\n<p>$select_res=$this-&gt;mysqli_BAE-&gt;execute_dql($select_sql);$rows=$select_res-&gt;fetch_array(MYSQLI_ASSOC);<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/dc91fb8cfedd1fafd5537a4b6bf7cca9-26.png\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe10\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe10\" \/><\/p>\n<p>10.4 \u6d4b\u8bd5\u66f4\u65b0\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>$update_sql=&#8221;UPDATE test_mysql SET password=&#8217;$new_password&#8217; WHERE from_user=&#8217;$fromUsername'&#8221;;<\/p>\n<p>$res = $this-&gt;mysqli_BAE-&gt;execute_dml($update_sql);<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/dc91fb8cfedd1fafd5537a4b6bf7cca9-27.png\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe11\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe11\" \/><\/p>\n<p>10.5 \u6d4b\u8bd5\u5220\u9664\u64cd\u4f5c<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>$delete_sql=&#8221;DELETE FROM test_mysql WHERE from_user=&#8217;$fromUsername'&#8221;;<\/p>\n<p>$res = $this-&gt;mysqli_BAE-&gt;execute_dml($delete_sql);<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/21b667c175248880cd9cf20bf94b2768-28.png\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe12\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u63d2\u56fe12\" \/><\/p>\n<p>\u4e0e\u5fae\u4fe1\u4ea4\u4e92\u6d4b\u8bd5\u6210\u529f\u3002&nbsp;<\/p>\n<p>\u3010\u76f8\u5173\u63a8\u8350\u3011<\/p>\n<p>1. <span><strong>\u7279\u522b\u63a8\u8350<\/strong><\/span>\uff1a<\/p>\n<p>2. <\/p>\n<p>3.&nbsp;<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5f00\u53d1\u4e4b\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5f00\u53d1 \u6570\u636e\u5e93\u64cd\u4f5c\u7684\u76f8\u5173\u8d44\u6599,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b \u4e00\u3001\u7b80\u4ecb \u524d\u9762\u8bb2\u89e3\u7684\u529f\u80fd\u5f00\u53d1\u90fd\u662f\u7b80\u5355\u7684\u8c03\u7528 \u5b8c\u6210\u7684\uff0c\u6ca1\u6709\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\u3002\u5728\u63a5\u4e0b\u6765\u7684\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5230\u6570\u636e\u5e93\uff0c\u6240\u4ee5\u5728\u8fd9\u4e00\u7bc7\u4e2d\uff0c\u5c06\u5bf9 \u6570\u636e\u5e93\u7684\u64cd\u4f5c\u505a\u4e00\u4e0b\u7b80\u5355\u7684\u4ecb\u7ecd\uff0c\u4ee5\u4f9b\u8bfb\u8005\u53c2\u8003\u3002 \u4e8c\u3001\u601d\u8def\u5206\u6790 \u767e\u5ea6\u5f00\u53d1\u8005\u4e2d\u5fc3\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4e91\u6570\u636e\u5e93\uff08\u5305\u62ecMySQL, , \uff09\uff0c\u5728\u8fd9\u4e00\u8282\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9\u5927\u5bb6\u6bd4\u8f83\u719f\u6089\u7684MySQL \u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\u6f14\u793a\uff0c\u5b9e\u73b0\u5fae\u4fe1\u4e0e\u6570\u636e\u5e93\u7684\u4ea4\u4e92\u3002 \u5728BAE\u5e94\u7528\u4e2d\u4f7f\u7528\u4e91\u6570\u636e\u5e93\u5341\u5206\u7b80\u5355\uff0c\u6570\u636e\u5e93\u5217\u8868\u4e2d\u7684\u540d\u79f0\u5373\u662f\u65f6\u7684dbname\u3002\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u8fde\u63a5\u5730\u5740\u548c\u7aef\u53e3\u5728\u5e94\u7528\u4e2d\u901a\u8fc7\u73af\u5883\u53d6\u51fa\u3002 \u53ef\u4f7f\u7528\u6807\u51c6\u7684PHP Mysql \u6216PHP Mysqli \u6269\u5c55\u8bbf\u95ee\u6570\u636e\u5e93\uff0cBAE\u7684PHP\u4e2d\u5df2\u63d0\u4f9b\u8fd9\u4e24\u4e2a\u6269\u5c55\uff0c\u5e94\u7528\u53ef\u76f4\u63a5\u4f7f\u7528\u3002 \u4e09\u3001\u521b\u5efaBAE 3.1 \u767b\u9646\u767e\u5ea6\u5f00\u53d1\u8005\u4e2d\u5fc3 -&gt; \u7ba1\u7406\u4e2d\u5fc3 -&gt; \u9009\u62e9\u5e94\u7528 -&gt; \u4e91\u73af\u5883 -&gt; \u670d\u52a1\u7ba1\u7406 -&gt; MySQL(\u4e91\u6570\u636e\u5e93) -&gt; 3.2 \u521b\u5efa\u6570\u636e\u5e93 \u6ce8\u610f\uff1a\u6bcf\u4e2a\u5e94\u7528\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e93\u4eab\u53d71G\u514d\u8d39\u914d\u989d\uff0c\u5176\u4f59\u6570\u636e\u5e93\u5747\u4e0d\u4eab\u53d7\u514d\u8d39\u914d\u989d\u4f18\u60e0\u3002\u53ea\u6709\u5c06\u5df2\u4f7f\u7528\u514d\u8d39\u914d\u989d\u7684\u6570\u636e\u5e93\uff0c\u624d\u80fd\u518d\u6b21\u4f7f\u7528\u6b64\u9879\u4f18\u60e0\u3002 3.3 \u521b\u5efa\u6210\u529f \u5728\u8fd9\u91cc\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5e93\u7684\u540d\u79f0\uff0c\u4e5f\u5c31\u662fdbname\uff0c\u540e\u9762\u4f1a\u4f7f\u7528\u5230\u3002 \u70b9\u51fb \u201cphpMyadmin\u201d \u8bbf\u95ee\u6570\u636e\u5e93\u3002 3.4 phpMyadmin\u754c\u9762 \u65b0\u5efa\u6570\u636e\u8868\uff0c\u8f93\u5165\u8868\u540d\u53ca\u5b57\u6bb5\u6570\uff0c\u70b9\u51fb \u201c\u6267\u884c\u201d \u521b\u5efa\u8868\u3002 3.5 \u521b\u5efa\u8868 \u8f93\u5165\u5b57\u6bb5\u540d\u53ca\u5b57\u6bb5\u7c7b\u578b\uff0c\u8f93\u5165\u5b8c\u6bd5\u540e\uff0c\u70b9\u51fb\u4e0b\u9762\u7684\u201c\u4fdd\u5b58\u201d\uff0c\u5b8c\u6210\u8868\u7684\u521b\u5efa\u3002 3.6 \u521b\u5efa\u5b8c\u6210 \u4fee\u6539id \u5b57\u6bb5\u4e3a\u4e3b\u952e\u5e76\u6dfb\u52a0AUTO_INCREMENT\uff1b\u4fee\u6539from_user \u5b57\u6bb5\u4e3a\u552f\u4e00\uff08UNIQUE\uff09\uff0c\u5b8c\u6210\u8868\u7684\u4fee\u6539\u3002 \u5efa\u8868\u64cd\u4f5c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\u5b8c\u6210\uff1a CREATE&nbsp;TABLE&nbsp;IF&nbsp;NOT&nbsp;EXISTS&nbsp;`test_mysql` [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-30158","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30158"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30158\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}