久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      解析laravel hasManyThrough如何用?

      下面由Laravel教程欄目給大家介紹laravel hasManyThrough用法及參數(shù),希望對(duì)大家有所幫助!

      第一種情況,我稱之為傳導(dǎo)關(guān)聯(lián)表(簡(jiǎn)單模式)

      國家有很多用戶,用戶有很多帖子

      countries     id - integer     name - string  users     id - integer     country_id - integer     name - string  posts     id - integer     user_id - integer     title - string

      查詢某個(gè)國家的所有帖子,怎么實(shí)現(xiàn)?

      countries為本表,posts為要輸出的目標(biāo)表,users為中間表

      return $this->hasManyThrough('AppPost', 'AppUser', 'country_id', 'user_id');

      第二種情況,有中間表情況(純中間表)

      exam_paper(試卷表)id nameexam_paper_question(試卷與試題中間表)id exam_paper_id question_idexam_question(試題表)id name

      我們要通過exam_paper的id查詢question

      return $this->hasManyThrough('exam_question', 'exam_paper_question', 'exam_paper_id', 'id','id','question_id');
      // 參數(shù)1 目標(biāo)表類名 exam_question, // 參數(shù)2 樞紐表類名 exam_paper_question, // 參數(shù)3 樞紐表中和當(dāng)前表關(guān)聯(lián)的字段名 'exam_paper_question.exam_paper_id', // 參數(shù)4 目標(biāo)表和樞紐表關(guān)聯(lián)的字段名 'exam_question.id', // 參數(shù)5 當(dāng)前表中和樞紐表關(guān)聯(lián)的字段名 'exam_paper.id', // 參數(shù)6 樞紐表和目標(biāo)表關(guān)聯(lián)的字段名 'exam_paper_question.question_id');

      如果把當(dāng)前表記作A,目標(biāo)表記作B,中間表記作C,6個(gè)參數(shù)記作(B,C,CA,BC,AC,CB)

      推薦學(xué)習(xí):《laravel視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)