thinkphp5 built-in paging function parameters did not get the second page, how to solve?

This switched: https://www.yunyingxbs.com/article/detail/id/342.html

The authors thank the selfless sharing!

Recently doing the project, using thinkphp5 (tp5) developed tp5 use the built-in paging capabilities.

So, the question is, when I use paginate function to generate pages, if there is no second page is not related, but when paging occurs, the results did not request parameters.

In other words, how to add parameters page, the second page of the search when no parameters, it is impossible to manually add it each time?

Find paginate function

Look carefully paginate function includes three parameters, as follows:

/ ** 
* paging query 
* @ paramint | array $ listRows per array represents the number of configuration parameters 
* @ paramint | bool $ simple compact mode or whether the total number of records 
* @ paramarray $ config configuration parameters 
* page: the current page, 
* path: url path, 
* Query: url additional parameters, 
* the fragment: url anchor, 
* var_page: page variable, 
* list_rows: page number 
* type: page class name 
* @ return \ of Think \ Paginator 
* @ throwsDbException 
* / 
publicfunctionpaginate ($ = null ListRows, $ = Simple to false, $ config = []) 
{

We can pass the original configuration parameters. Then it is a good reality.

Solution

$userlist=model('User')->where("namelike'%{$name}%'")->paginate(12,false,[
'query'=>request()->param(),
]);

The request parameters with the past on it!

 

Guess you like

Origin www.cnblogs.com/huhewei/p/11993174.html