{"id":164023,"date":"2024-11-05T04:23:51","date_gmt":"2024-11-04T20:23:51","guid":{"rendered":"https:\/\/server.hk\/cnblog\/164023\/"},"modified":"2024-11-05T04:23:52","modified_gmt":"2024-11-04T20:23:52","slug":"%e8%a7%a3%e6%9e%90phpcms2023%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%87%e4%bb%b6-phpcms2023%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/164023\/","title":{"rendered":"\u89e3\u6790PHPCMS2023\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6 (phpcms2023\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6)"},"content":{"rendered":"<h1 id=\"%e8%a7%a3%e6%9e%90phpcms2023%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%87%e4%bb%b6-ryubnllWsG\">\u89e3\u6790PHPCMS2023\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u5167\u5bb9\u7ba1\u7406\u7cfb\u7d71\uff08CMS\uff09\u626e\u6f14\u8457\u81f3\u95dc\u91cd\u8981\u7684\u89d2\u8272\u3002PHPCMS\u4f5c\u70ba\u4e00\u6b3e\u6d41\u884c\u7684\u958b\u6e90CMS\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u985e\u7db2\u7ad9\u7684\u5efa\u8a2d\u4e2d\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0ePHPCMS2023\u7684\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u597d\u5730\u7406\u89e3\u5176\u7d50\u69cb\u548c\u529f\u80fd\u3002<\/p>\n<h2 id=\"phpcms2023%e6%a6%82%e8%bf%b0-ryubnllWsG\">PHPCMS2023\u6982\u8ff0<\/h2>\n<p>PHPCMS2023\u662f\u4e00\u500b\u57fa\u65bcPHP\u548cMySQL\u7684\u5167\u5bb9\u7ba1\u7406\u7cfb\u7d71\uff0c\u65e8\u5728\u63d0\u4f9b\u9748\u6d3b\u4e14\u9ad8\u6548\u7684\u7db2\u7ad9\u5efa\u8a2d\u89e3\u6c7a\u65b9\u6848\u3002\u5b83\u7684\u67b6\u69cb\u8a2d\u8a08\u4f7f\u5f97\u7528\u6236\u80fd\u5920\u8f15\u9b06\u5730\u7ba1\u7406\u7db2\u7ad9\u5167\u5bb9\uff0c\u4e26\u4e14\u652f\u6301\u591a\u7a2e\u64f4\u5c55\u529f\u80fd\u3002\u6578\u64da\u5eab\u9023\u63a5\u662fPHPCMS\u904b\u884c\u7684\u6838\u5fc3\u90e8\u5206\uff0c\u8ca0\u8cac\u8207\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%87%e4%bb%b6%e7%9a%84%e7%b5%90%e6%a7%8b-ryubnllWsG\">\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6\u7684\u7d50\u69cb<\/h2>\n<p>\u5728PHPCMS2023\u4e2d\uff0c\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u7cfb\u7d71\u7684\u6839\u76ee\u9304\u4e0b\uff0c\u540d\u70ba<code>config.php<\/code>\u3002\u9019\u500b\u6587\u4ef6\u5305\u542b\u4e86\u6578\u64da\u5eab\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u6a5f\u540d\u3001\u7528\u6236\u540d\u3001\u5bc6\u78bc\u548c\u6578\u64da\u5eab\u540d\u7a31\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u5178\u578b\u7684\u6578\u64da\u5eab\u9023\u63a5\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<pre><code>&lt;?php\nreturn array(\n    'db_type' =&gt; 'mysql',\n    'db_host' =&gt; 'localhost',\n    'db_user' =&gt; 'your_username',\n    'db_pass' =&gt; 'your_password',\n    'db_name' =&gt; 'your_database',\n    'db_charset' =&gt; 'utf8',\n);\n?&gt;<\/code><\/pre>\n<h3 id=\"%e5%90%84%e9%a0%85%e9%85%8d%e7%bd%ae%e5%8f%83%e6%95%b8%e8%a7%a3%e6%9e%90-ryubnllWsG\">\u5404\u9805\u914d\u7f6e\u53c3\u6578\u89e3\u6790<\/h3>\n<ul>\n<li><strong>db_type<\/strong>: \u6578\u64da\u5eab\u985e\u578b\uff0c\u901a\u5e38\u70ba&#8217;mysql&#8217;\u3002<\/li>\n<li><strong>db_host<\/strong>: \u6578\u64da\u5eab\u4f3a\u670d\u5668\u7684\u5730\u5740\uff0c\u901a\u5e38\u70ba&#8217;localhost&#8217;\uff0c\u4e5f\u53ef\u4ee5\u662f\u9060\u7a0b\u4f3a\u670d\u5668\u7684IP\u5730\u5740\u3002<\/li>\n<li><strong>db_user<\/strong>: \u7528\u65bc\u9023\u63a5\u6578\u64da\u5eab\u7684\u7528\u6236\u540d\u3002<\/li>\n<li><strong>db_pass<\/strong>: \u5c0d\u61c9\u7684\u7528\u6236\u5bc6\u78bc\u3002<\/li>\n<li><strong>db_name<\/strong>: \u8981\u9023\u63a5\u7684\u6578\u64da\u5eab\u540d\u7a31\u3002<\/li>\n<li><strong>db_charset<\/strong>: \u6578\u64da\u5eab\u5b57\u7b26\u96c6\uff0c\u901a\u5e38\u8a2d\u7f6e\u70ba&#8217;utf8&#8217;\u4ee5\u652f\u6301\u591a\u8a9e\u8a00\u5167\u5bb9\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e7%9a%84%e5%af%a6%e7%8f%be-ryubnllWsG\">\u6578\u64da\u5eab\u9023\u63a5\u7684\u5be6\u73fe<\/h2>\n<p>\u5728PHPCMS\u4e2d\uff0c\u6578\u64da\u5eab\u9023\u63a5\u7684\u5be6\u73fe\u901a\u5e38\u4f7f\u7528PDO\uff08PHP Data Objects\uff09\u6216MySQLi\u64f4\u5c55\u3002\u9019\u4e9b\u64f4\u5c55\u63d0\u4f9b\u4e86\u5b89\u5168\u4e14\u9ad8\u6548\u7684\u6578\u64da\u5eab\u64cd\u4f5c\u65b9\u5f0f\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528PDO\u9032\u884c\u6578\u64da\u5eab\u9023\u63a5\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>&lt;?php\n$config = include('config.php');\n\ntry {\n    $pdo = new PDO(\"{$config['db_type']}:host={$config['db_host']};dbname={$config['db_name']}\", $config['db_user'], $config['db_pass']);\n    $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n    echo \"\u6210\u529f\u9023\u63a5\u5230\u6578\u64da\u5eab\uff01\";\n} catch (PDOException $e) {\n    echo \"\u9023\u63a5\u5931\u6557: \" . $e-&gt;getMessage();\n}\n?&gt;<\/code><\/pre>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-ryubnllWsG\">\u5e38\u898b\u554f\u984c\u53ca\u89e3\u6c7a\u65b9\u6848<\/h2>\n<p>\u5728\u4f7f\u7528PHPCMS2023\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u5e38\u898b\u7684\u6578\u64da\u5eab\u9023\u63a5\u554f\u984c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u6c7a\u65b9\u6848\uff1a<\/p>\n<ul>\n<li><strong>\u7121\u6cd5\u9023\u63a5\u5230\u6578\u64da\u5eab<\/strong>: \u6aa2\u67e5<code>config.php<\/code>\u4e2d\u7684\u914d\u7f6e\u4fe1\u606f\u662f\u5426\u6b63\u78ba\uff0c\u7279\u5225\u662f\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002<\/li>\n<li><strong>\u6578\u64da\u5eab\u5b57\u7b26\u96c6\u554f\u984c<\/strong>: \u78ba\u4fdd\u6578\u64da\u5eab\u548c\u8868\u7684\u5b57\u7b26\u96c6\u8a2d\u7f6e\u70ba&#8217;utf8&#8217;\uff0c\u4ee5\u907f\u514d\u4e2d\u6587\u986f\u793a\u554f\u984c\u3002<\/li>\n<li><strong>PDO\u64f4\u5c55\u672a\u555f\u7528<\/strong>: \u78ba\u4fddPHP\u74b0\u5883\u4e2d\u5df2\u555f\u7528PDO\u64f4\u5c55\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ryubnllWsG\">\u7e3d\u7d50<\/h2>\n<p>PHPCMS2023\u7684\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6\u662f\u7cfb\u7d71\u904b\u884c\u7684\u57fa\u790e\uff0c\u6b63\u78ba\u7684\u914d\u7f6e\u548c\u5be6\u73fe\u5c0d\u65bc\u7db2\u7ad9\u7684\u7a69\u5b9a\u6027\u81f3\u95dc\u91cd\u8981\u3002\u901a\u904e\u7406\u89e3\u6578\u64da\u5eab\u9023\u63a5\u7684\u7d50\u69cb\u548c\u5e38\u898b\u554f\u984c\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u7ba1\u7406\u548c\u7dad\u8b77\u5176\u7db2\u7ad9\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684PHPCMS\u7db2\u7ad9\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u89e3\u6790PHPCMS2023\u6578\u64da\u5eab\u9023\u63a5\u6587\u4ef6\uff0c\u4e86\u89e3\u5176\u7d50\u69cb\u8207\u914d\u7f6e\uff0c\u52a9\u60a8\u8f15\u9b06\u7ba1\u7406\u7db2\u7ad9\u6578\u64da\u5eab\u9023\u63a5\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-164023","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=164023"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164023\/revisions"}],"predecessor-version":[{"id":164024,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164023\/revisions\/164024"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=164023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=164023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=164023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}