Pagination display problem of ThinkPHP categorical data

【Foreword】

    Question: The categorical data queried through the joint table is instantiated and displayed several times when displayed in pagination?

    As shown below:

The first page renderings:

The second page renderings:

   The above is the problem encountered, after thinking for a long time, and even using the native grammar. Just found the reason, it turned out to be very simple. . . . Because after the data is queried, I forgot to add paging syntax in the combined table query syntax . .

   The original incorrect syntax:

 

$model->field('t1.*,t2.catename as catename')
      ->alias('t1')
      ->join('left join blog_cate as t2 on t1.cateid=t2.id')
      ->where('t1.cateid = '.I('id'))
      ->select();

There is no paging syntax here, so it is instantiated multiple times to solve the syntax:

$model->field('t1.*,t2.catename as catename')
      ->alias('t1')
      ->join('left join blog_cate as t2 on t1.cateid=t2.id')
      ->limit($Page->firstRow.','.$Page->listRows)
      ->where('t1.cateid = '.I('id'))
      ->select();

 Add upper pagination syntax

 

 

 

 

 

 

 

 

 

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326058742&siteId=291194637