<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                遠程一對多關聯用于定義有跨表的一對多關系,例如: * 每個城市有多個用戶 * 每個用戶有多個話題 * 城市和話題之間并無關聯 ## 關聯定義 就可以直接通過遠程一對多關聯獲取每個城市的多個話題,`City`模型定義如下: ~~~ <?php namespace app\index\model; use think\Model; class City extends Model { public function topics() { return $this->hasManyThrough('Topic','User'); } } ~~~ 遠程一對多關聯,需要同時存在`Topic`和`User`模型。 `hasManyThrough`方法的參數如下: >[info] ### hasManyThrough('關聯模型','中間模型','外鍵','中間表關聯鍵','主鍵'); * **關聯模型**(必須):模型名或者模型類名 * **中間模型**(必須):模型名或者模型類名 * **外鍵**:默認的外鍵名規則是當前模型名+`_id` * **中間表關聯鍵**:默認的中間表關聯鍵名的規則是中間模型名+`_id` * **主鍵**:當前模型主鍵,一般會自動獲取也可以指定傳入 ## 關聯查詢 我們可以通過下面的方式獲取關聯數據 ~~~ $city = City::get(1); // 獲取同城的所有話題 dump($city->topics); // 也可以進行條件搜索 dump($city->topics()->where('topic.status',1)->select()); ~~~ > 條件搜索的時候,需要帶上模型名作為前綴
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看