Home  >  Q&A  >  body text

Looking for a way to use models to perform multi-table related queries under TP5?


Dear masters, when I use tp5 to query multiple tables, I use the view query method, similar to Db::view('table_a')->view('table_b')-> view('table_c')->view('table_d')->view('table_e')->select(). If you want to use model classes to do this, it is similar to many What method should be used to perform related queries on tables (more than 5)? Do we need to create an inter-table association model for each table and then string them together for use? Thank you!

阳光阳光2174 days ago1819

reply all(4)I'll reply

  • Autumn

    Autumn2018-10-11 11:11:11

    DB::table('Table1') ->alias('a')    ->field(")    ->where( $where)    ->join('data table d','a.id=d.id','left')     ;->join('')    ->join('')    ->order('' )    ->page()    -> select(); In this way, no matter how many tables you have, you can join them

    reply
    0
  • *

    *2018-10-11 00:13:39

    Does anyone know the steps and principles of creating and installing a PHP website? Can you please explain? ? ?

    reply
    0
  • *

    *2018-10-11 00:13:09

    PHP website creation and installation procedure steps and principles

    reply
    0
  • Don't cry

    Don't cry2018-10-10 10:46:44

    Generally speaking, it is rarely used to query the five tables you mentioned. If necessary, it is mostly because there is a problem with your business logic or database design. Don't worry too much about this issue

    reply
    0
  • 阳光

    Thank you very much for the reminder, thank you

    阳光 · 2018-10-10 12:18:36
  • Cancelreply