<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>

                # ThinkPhP5 視頻教程(十九講):關聯-一(一對多) ![](https://box.kancloud.cn/716b48b471d20c634af52f3915ec0efa_953x662.png) ![](https://box.kancloud.cn/0055e879ff99de3fe50f9f42ea207d24_1205x737.png) * 一對多關聯 每個用戶有多個評論就是一個典型的一對多關聯 * 關聯定義 在User模型類添加Comment關聯如下: ~~~ <?php namespace app\index\model; use think\Model; class Users extends Model { // 定義關聯方法 public function comm() { return $this->hasMany('Comment','uid','user_id'); } } ~~~ hasMany的參數如下: > hasMany('關聯模型名','關聯外鍵','關聯模型主鍵','別名定義') 如果需要定義對應的關聯,則可以使用belongsTo方法: ~~~ <?php namespace app\index\model; use think\Model; class Comment extends Model { // 定義關聯方法 public function user() { return $this->belongsTo('Users','user_id','uid'); } } ~~~ * 關聯新增 ~~~ public function test19() { // 一對多批量新增 $user = Users::get(1); $comment = [ ['content' => 'ThinkPHP5視頻教程', 'add_time' =>time()], ['content' => 'TP5視頻教程', 'add_time' => time()], ]; $user->comm()->saveAll($comment); return '添加comm成功'; } ~~~ 如果需要數據表的, 請前往TPshop官網下載. ~~~[youku] XMjc0MDY3MjE1Mg =856x523 ~~~ **TP5粉絲群: 543608226** 視頻播放密碼: tp009 Demo下載地址: https://pan.baidu.com/s/1pLTMYRT [需要TPshop商城源碼的可前往TPshop官網免費下載安裝](http://www.tp-shop.cn)
                  <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>

                              哎呀哎呀视频在线观看