{"id":23938,"date":"2024-11-21T08:55:42","date_gmt":"2024-11-21T00:55:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23938\/"},"modified":"2024-11-21T08:55:42","modified_gmt":"2024-11-21T00:55:42","slug":"%e4%bd%bf%e7%94%a8yii%e6%a1%86%e6%9e%b6%e5%88%9b%e5%bb%ba%e5%9b%be%e4%b9%a6%e9%a6%86%e7%bd%91%e7%ab%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23938\/","title":{"rendered":"\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9"},"content":{"rendered":"<p>\u968f\u7740\u6570\u5b57\u5316\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u56fe\u4e66\u9986\u4e5f\u9010\u6e10\u5b9e\u73b0\u4e86\u81ea\u5df1\u7684\u6570\u5b57\u5316\u8f6c\u578b\uff0c\u4ece\u4f20\u7edf\u7684\u7eb8\u8d28\u5316\u7ba1\u7406\u9010\u6e10\u8f6c\u5411\u6570\u5b57\u5316\u7ba1\u7406\u3002\u800c\u5728\u6570\u5b57\u5316\u7ba1\u7406\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u7f51\u7ad9\u5e94\u7528\u7a0b\u5e8f\u6765\u5b9e\u73b0\u56fe\u4e66\u9986\u7684\u7ba1\u7406\u5df2\u7ecf\u6210\u4e3a\u4e86\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u65b9\u5f0f\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u56fe\u4e66\u9986\u66f4\u597d\u5730\u7ba1\u7406\u56fe\u4e66\u3001\u501f\u9605\u8bb0\u5f55\u3001\u7528\u6237\u8d26\u6237\u7b49\u4fe1\u606f\u3002\u800c\u4f7f\u7528yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9\u4e5f\u6210\u4e3a\u4e86\u4e00\u79cd\u975e\u5e38\u7b80\u5355\u6709\u6548\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9\u3002<\/p>\n<ol>\n<li>Yii\u6846\u67b6\u7b80\u4ecb<\/li>\n<\/ol>\n<p>Yii\u6846\u67b6\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684PHP\u6846\u67b6\uff0c\u5b83\u4f7f\u7528MVC(Model-View-Controller)\u6a21\u5f0f\u6765\u5b9e\u73b0Web\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u3002\u8be5\u6846\u67b6\u63d0\u4f9b\u4e86\u4e00\u5957\u7b80\u5355\u3001\u9ad8\u6548\u7684\u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u4ee5\u53ca\u4e00\u4e9b\u5185\u7f6e\u7684\u4f18\u79c0\u7279\u6027\uff0c\u5982Active Record\u7b49\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u521b\u5efa\u51fa\u9ad8\u6027\u80fd\u7684Web\u5e94\u7528\u7a0b\u5e8f\uff0c\u9002\u7528\u4e8e\u5404\u7c7b\u5927\u5c0f\u7684\u4f01\u4e1a\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>Yii\u6846\u67b6\u7684\u7279\u70b9\uff1a<\/p>\n<ol>\n<li>\u9ad8\u6027\u80fd\uff1aYii\u6846\u67b6\u88ab\u8bbe\u8ba1\u4e3a\u4e00\u79cd\u9ad8\u6027\u80fd\u7684PHP\u6846\u67b6\uff0c\u5b83\u901a\u8fc7\u4f7f\u7528\u8bf8\u5982\u52a8\u6001\u52a0\u8f7d\u7b49\u6280\u672f\uff0c\u63d0\u9ad8\u4e86Web\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<\/li>\n<li>\u9ad8\u6548\uff1aYii\u6846\u67b6\u63d0\u4f9b\u4e86\u5f88\u591a\u5185\u7f6e\u7684\u5de5\u5177\u548c\u7ec4\u4ef6\uff0c\u5b83\u4eec\u53ef\u4ee5\u7528\u6765\u4f18\u5316\u6570\u636e\u8bbf\u95ee\u3001\u6a21\u578b\u89c6\u56fe\u534f\u540c\u7b49\u5404\u79cd\u5e94\u7528\u573a\u666f\u3002<\/li>\n<li>\u7b80\u5355\uff1aYii\u6846\u67b6\u7684\u8bed\u6cd5\u7b80\u5355\u6613\u61c2\uff0c\u4ee3\u7801\u5199\u8d77\u6765\u4e5f\u975e\u5e38\u65b9\u4fbf\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e00\u4e2a\u9002\u5408PHP\u5f00\u53d1\u8005\u4f7f\u7528\u7684Web\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u3002<\/li>\n<li>\u521b\u5efa\u56fe\u4e66\u9986Web\u5e94\u7528\u7a0b\u5e8f<\/li>\n<\/ol>\n<p>2.1 \u521b\u5efaYii\u5de5\u7a0b<\/p>\n<p>\u9996\u5148\u9700\u8981\u521b\u5efaYii\u6846\u67b6\u7684\u5de5\u7a0b\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre> yiic.php webapp bookstore<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d &#8220;bookstore&#8221; \u662f\u6211\u4eec\u8981\u521b\u5efa\u7684Yii\u5de5\u7a0b\u540d\u79f0\u3002\u8be5\u547d\u4ee4\u4f1a\u4e3a\u60a8\u521b\u5efa\u51fa\u4e00\u4e2a\u5b8c\u6574\u7684Yii\u5de5\u7a0b\u3002<\/p>\n<p>2.2 \u6570\u636e\u8868\u8bbe\u8ba1<\/p>\n<p>\u56fe\u4e66\u9986\u7ba1\u7406\u7cfb\u7edf\u9700\u8981\u8bbe\u8ba1\u4ee5\u4e0b\u6570\u636e\u8868\uff1a<\/p>\n<ul>\n<li>\u56fe\u4e66\u8868(book)<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5\u540d<\/th>\n<th>\u5b57\u6bb5\u7c7b\u578b<\/th>\n<th>\u7ea6\u675f\u6761\u4ef6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>book_id<\/td>\n<td>int(11)<\/td>\n<td>PRIMARY KEY AUTO INCREMENT<\/td>\n<\/tr>\n<tr>\n<td>book_name<\/td>\n<td>varchar(255)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>author<\/td>\n<td>varchar(255)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>publisher<\/td>\n<td>varchar(255)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>publish_date<\/td>\n<td>date<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>isbn<\/td>\n<td>varchar(20)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u8bfb\u8005\u8868(reader)<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5\u540d<\/th>\n<th>\u5b57\u6bb5\u7c7b\u578b<\/th>\n<th>\u7ea6\u675f\u6761\u4ef6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>reader_id<\/td>\n<td>int(11)<\/td>\n<td>PRIMARY KEY AUTO INCREMENT<\/td>\n<\/tr>\n<tr>\n<td>reader_name<\/td>\n<td>varchar(255)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>phone<\/td>\n<td>varchar(20)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>email<\/td>\n<td>varchar(255)<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>address<\/td>\n<td>varchar(255)<\/td>\n<td>DEFAULT NULL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u501f\u9605\u8bb0\u5f55\u8868(borrow)<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5\u540d<\/th>\n<th>\u5b57\u6bb5\u7c7b\u578b<\/th>\n<th>\u7ea6\u675f\u6761\u4ef6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>borrow_id<\/td>\n<td>int(11)<\/td>\n<td>PRIMARY KEY AUTO INCREMENT<\/td>\n<\/tr>\n<tr>\n<td>book_id<\/td>\n<td>int(11)<\/td>\n<td>ForeignKey(book)<\/td>\n<\/tr>\n<tr>\n<td>reader_id<\/td>\n<td>int(11)<\/td>\n<td>ForeignKey(reader)<\/td>\n<\/tr>\n<tr>\n<td>borrow_date<\/td>\n<td>datetime<\/td>\n<td>NOT NULL<\/td>\n<\/tr>\n<tr>\n<td>return_date<\/td>\n<td>datetime<\/td>\n<td>DEFAULT NULL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u521b\u5efa\u4ee5\u4e0a\u4e09\u4e2a\u6570\u636e\u8868\u3002<\/p>\n<p>2.3 \u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e<\/p>\n<p>\u5728config.php\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u4fe1\u606f\u3002<\/p>\n<pre>\/\/ \u6570\u636e\u5e93\u914d\u7f6e\n'db'=&amp;gt;array(\n    'connectionString' =&amp;gt; 'mysql:host=localhost;dbname=bookstore',\n    'emulatePrepare' =&amp;gt; true,\n    'username' =&amp;gt; 'root',\n    'password' =&amp;gt; '123456',\n    'charset' =&amp;gt; 'utf8',\n    'tablePrefix' =&amp;gt; '',\n),<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u91cc\u914d\u7f6e\u7684\u662fmysql\u6570\u636e\u5e93\uff0c\u76f4\u63a5\u4fee\u6539\u6210\u60a8\u7684\u6570\u636e\u5e93\u914d\u7f6e\u5373\u53ef\u3002<\/p>\n<p>2.4 \u521b\u5efa\u6a21\u578b\u6587\u4ef6<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528Yii\u6846\u67b6\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u5730\u751f\u6210\u6a21\u578b\u6587\u4ef6\uff0c\u57fa\u4e8e\u73b0\u6709\u7684\u6570\u636e\u8868\u6765\u521b\u5efa\u6a21\u578b\u7c7b\u3002<\/p>\n<pre> yiic sample-model book<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u60a8\u53ef\u4ee5\u7528\u4ee5\u4e0a\u547d\u4ee4\u6765\u751f\u6210\u4e00\u4e2abook\u7684\u6a21\u578b\u7c7b\u3002\u8fd9\u4e2a\u7c7b\u4f7f\u7528Yii\u7684active record\u6280\u672f\uff0c\u83b7\u53d6\u6570\u636e\u8868\u4e2d\u7684\u4fe1\u606f\u5e76\u5bf9\u5176\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<p>2.5 \u521b\u5efa\u63a7\u5236\u5668\u6587\u4ef6<\/p>\n<p>\u63a7\u5236\u5668\u662f\u8fde\u63a5\u6a21\u578b\u548c\u89c6\u56fe\u7684\u6865\u6881\uff0c\u5b83\u8d1f\u8d23\u5904\u7406\u6765\u81ea\u89c6\u56fe\u7684\u7528\u6237\u8bf7\u6c42\uff0c\u5e76\u5bf9\u6a21\u578b\u8fdb\u884c\u5904\u7406\u548c\u64cd\u4f5c\uff0c\u6700\u540e\u5c06\u9700\u8981\u7684\u7ed3\u679c\u5448\u73b0\u7ed9\u7528\u6237\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u5730\u751f\u6210\u4e00\u4e2a\u7b80\u5355\u7684\u63a7\u5236\u5668\uff1a<\/p>\n<pre> yiic sample-controller book<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u4e3a\u60a8\u751f\u6210\u4e00\u4e2abook\u7684\u63a7\u5236\u5668\u7c7b\uff0c\u5e76\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u64cd\u4f5c\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u64cd\u4f5c\u540d<\/th>\n<th>\u64cd\u4f5c\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Create<\/td>\n<td>\u521b\u5efa\u4e00\u672c\u4e66<\/td>\n<\/tr>\n<tr>\n<td>Read<\/td>\n<td>\u8bfb\u53d6\u4e00\u672c\u4e66<\/td>\n<\/tr>\n<tr>\n<td>Update<\/td>\n<td>\u66f4\u65b0\u4e00\u672c\u4e66<\/td>\n<\/tr>\n<tr>\n<td>Delete<\/td>\n<td>\u5220\u9664\u4e00\u672c\u4e66<\/td>\n<\/tr>\n<tr>\n<td>List<\/td>\n<td>\u5c55\u793a\u6240\u6709\u4e66\u7c4d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>2.6 \u521b\u5efa\u89c6\u56fe\u6587\u4ef6<\/p>\n<p>\u89c6\u56fe\u6587\u4ef6\u662f\u5c55\u793a\u7ed9\u7528\u6237\u7684\u6700\u7ec8\u4fe1\u606f\u3002\u901a\u8fc7\u4f7f\u7528Yii\u6846\u67b6\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u5730\u751f\u6210\u89c6\u56fe\u6587\u4ef6\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e9b\u5728\u89c6\u56fe\u6587\u4ef6\u4e2d\u4f7f\u7528\u7684\u547d\u4ee4\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u7528\u9014<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>echo<\/td>\n<td>\u8f93\u51fa\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td>beginWidget<\/td>\n<td>\u5f00\u59cb\u4e00\u4e2a\u7ec4\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>endWidget<\/td>\n<td>\u7ed3\u675f\u4e00\u4e2a\u7ec4\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>CHtml<\/td>\n<td>\u751f\u6210HTML\u6807\u7b7e<\/td>\n<\/tr>\n<tr>\n<td>submitButton<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u63d0\u4ea4\u6309\u94ae<\/td>\n<\/tr>\n<tr>\n<td>label<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u6807\u7b7e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u60a8\u53ef\u4ee5\u5229\u7528\u4ee5\u4e0a\u547d\u4ee4\u521b\u5efa\u89c6\u56fe\u6587\u4ef6\uff0c\u5e76\u5c06\u5b83\u4eec\u548c\u63a7\u5236\u5668\u4ee3\u7801\u7ed3\u5408\u8d77\u6765\uff0c\u901a\u8fc7\u6a21\u677f\u6e32\u67d3\uff0c\u5b9e\u73b0\u5bf9\u7528\u6237\u7684\u76f4\u63a5\u5448\u73b0\u3002<\/p>\n<ol>\n<li>\u603b\u7ed3<\/li>\n<\/ol>\n<p>\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986Web\u5e94\u7528\u7a0b\u5e8f\u662f\u4e00\u79cd\u5f88\u597d\u7684\u65b9\u6cd5\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u4e86\u89e3Yii\u6846\u67b6\u7684\u57fa\u672c\u6982\u5ff5\u548c\u4f7f\u7528\u65b9\u6cd5\uff0c\u4ee5\u53ca\u56fe\u4e66\u9986\u7ba1\u7406\u8fc7\u7a0b\u4e2d\u9700\u8981\u7528\u5230\u7684\u4e00\u4e9b\u76f8\u5173\u77e5\u8bc6\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u591f\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3Yii\u6846\u67b6\u548c\u56fe\u4e66\u9986\u7ba1\u7406\u7cfb\u7edf\u7684\u5f00\u53d1\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9\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>\u968f\u7740\u6570\u5b57\u5316\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u56fe\u4e66\u9986\u4e5f\u9010\u6e10\u5b9e\u73b0\u4e86\u81ea\u5df1\u7684\u6570\u5b57\u5316\u8f6c\u578b\uff0c\u4ece\u4f20\u7edf\u7684\u7eb8\u8d28\u5316\u7ba1\u7406\u9010\u6e10\u8f6c\u5411\u6570\u5b57\u5316\u7ba1\u7406\u3002\u800c\u5728\u6570\u5b57\u5316\u7ba1\u7406\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u7f51\u7ad9\u5e94\u7528\u7a0b\u5e8f\u6765\u5b9e\u73b0\u56fe\u4e66\u9986\u7684\u7ba1\u7406\u5df2\u7ecf\u6210\u4e3a\u4e86\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u65b9\u5f0f\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u56fe\u4e66\u9986\u66f4\u597d\u5730\u7ba1\u7406\u56fe\u4e66\u3001\u501f\u9605\u8bb0\u5f55\u3001\u7528\u6237\u8d26\u6237\u7b49\u4fe1\u606f\u3002\u800c\u4f7f\u7528yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9\u4e5f\u6210\u4e3a\u4e86\u4e00\u79cd\u975e\u5e38\u7b80\u5355\u6709\u6548\u7684\u65b9\u5f0f\u3002 \u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Yii\u6846\u67b6\u521b\u5efa\u56fe\u4e66\u9986\u7f51\u7ad9\u3002 Yii\u6846\u67b6\u7b80\u4ecb Yii\u6846\u67b6\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684PHP\u6846\u67b6\uff0c\u5b83\u4f7f\u7528MVC(Model-View-Controller)\u6a21\u5f0f\u6765\u5b9e\u73b0Web\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u3002\u8be5\u6846\u67b6\u63d0\u4f9b\u4e86\u4e00\u5957\u7b80\u5355\u3001\u9ad8\u6548\u7684\u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u4ee5\u53ca\u4e00\u4e9b\u5185\u7f6e\u7684\u4f18\u79c0\u7279\u6027\uff0c\u5982Active Record\u7b49\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u521b\u5efa\u51fa\u9ad8\u6027\u80fd\u7684Web\u5e94\u7528\u7a0b\u5e8f\uff0c\u9002\u7528\u4e8e\u5404\u7c7b\u5927\u5c0f\u7684\u4f01\u4e1a\u5e94\u7528\u7a0b\u5e8f\u3002 Yii\u6846\u67b6\u7684\u7279\u70b9\uff1a \u9ad8\u6027\u80fd\uff1aYii\u6846\u67b6\u88ab\u8bbe\u8ba1\u4e3a\u4e00\u79cd\u9ad8\u6027\u80fd\u7684PHP\u6846\u67b6\uff0c\u5b83\u901a\u8fc7\u4f7f\u7528\u8bf8\u5982\u52a8\u6001\u52a0\u8f7d\u7b49\u6280\u672f\uff0c\u63d0\u9ad8\u4e86Web\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u3002 \u9ad8\u6548\uff1aYii\u6846\u67b6\u63d0\u4f9b\u4e86\u5f88\u591a\u5185\u7f6e\u7684\u5de5\u5177\u548c\u7ec4\u4ef6\uff0c\u5b83\u4eec\u53ef\u4ee5\u7528\u6765\u4f18\u5316\u6570\u636e\u8bbf\u95ee\u3001\u6a21\u578b\u89c6\u56fe\u534f\u540c\u7b49\u5404\u79cd\u5e94\u7528\u573a\u666f\u3002 \u7b80\u5355\uff1aYii\u6846\u67b6\u7684\u8bed\u6cd5\u7b80\u5355\u6613\u61c2\uff0c\u4ee3\u7801\u5199\u8d77\u6765\u4e5f\u975e\u5e38\u65b9\u4fbf\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e00\u4e2a\u9002\u5408PHP\u5f00\u53d1\u8005\u4f7f\u7528\u7684Web\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u3002 \u521b\u5efa\u56fe\u4e66\u9986Web\u5e94\u7528\u7a0b\u5e8f 2.1 \u521b\u5efaYii\u5de5\u7a0b \u9996\u5148\u9700\u8981\u521b\u5efaYii\u6846\u67b6\u7684\u5de5\u7a0b\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a yiic.php webapp bookstore \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d &#8220;bookstore&#8221; \u662f\u6211\u4eec\u8981\u521b\u5efa\u7684Yii\u5de5\u7a0b\u540d\u79f0\u3002\u8be5\u547d\u4ee4\u4f1a\u4e3a\u60a8\u521b\u5efa\u51fa\u4e00\u4e2a\u5b8c\u6574\u7684Yii\u5de5\u7a0b\u3002 2.2 \u6570\u636e\u8868\u8bbe\u8ba1 \u56fe\u4e66\u9986\u7ba1\u7406\u7cfb\u7edf\u9700\u8981\u8bbe\u8ba1\u4ee5\u4e0b\u6570\u636e\u8868\uff1a \u56fe\u4e66\u8868(book) \u5b57\u6bb5\u540d \u5b57\u6bb5\u7c7b\u578b \u7ea6\u675f\u6761\u4ef6 book_id int(11) PRIMARY KEY AUTO INCREMENT book_name varchar(255) NOT NULL author varchar(255) NOT NULL publisher varchar(255) NOT NULL publish_date date NOT NULL isbn varchar(20) NOT NULL \u8bfb\u8005\u8868(reader) \u5b57\u6bb5\u540d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-23938","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23938","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=23938"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23938\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}