{"id":89651,"date":"2019-08-01T16:06:01","date_gmt":"2019-08-01T08:06:01","guid":{"rendered":"http:\/\/4563.org\/?p=89651"},"modified":"2019-08-01T16:06:01","modified_gmt":"2019-08-01T08:06:01","slug":"yii2-with-%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=89651","title":{"rendered":"yii2 with \u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  yii2 with \u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fangwenxue <\/span>  <span><i><\/i> 74<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>UserHistory<\/h2>\n<pre><code>self::find()-&gt;with('book.lastItem')-&gt;where(\"uid = {$uid}\")-&gt;orderBy('id desc')-&gt;asArray()-&gt;all();   public function getBook() {  return $this-&gt;hasOne(Book::class, ['id' =&gt; 'book_id']); } <\/code><\/pre>\n<h2>Book<\/h2>\n<pre><code>public function getLatItem(){  return $this-&gt;hasOne(BookItem::class, ['book_id' =&gt; 'id'])-&gt;orderBy('id desc'); } <\/code><\/pre>\n<ul>\n<li>\n<p>appmodelsBook has no relation named &#8220;lastItem&#8221;.<\/p>\n<\/li>\n<li>\n<p>with \u4e0d\u652f\u6301\u6211\u8fd9\u79cd\u5199\u6cd5\u8fd8\u662f\uff1f<\/p>\n<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"586353\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : emeab <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 with \u4e0d\u5982\u81ea\u5df1 join \u6216\u8005\u81ea\u5df1\u67e5\u518d\u62fc\u8d77\u6765                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"586354\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fangwenxue <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @emeab <br \/>\u627e\u5230\u95ee\u9898\u4e86\uff0cgetLatItem \u65b9\u6cd5\u540d\u9519\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"586355\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhzhwcn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             `book.lastItem` VS `getLatItem`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"586618\" data-uid=\"3\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : \u6e38\u5ba2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u5b57                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>yii2 with \u95ee\u9898 \u8cc7\u6df1\u5927\u4f6c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/89651"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89651"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/89651\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89651"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}