Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about the absence of data classification instructions in the official manual of version 3.2. I tried to debug it today and it basically works, for beginners.
First
Import ('org. Util. page'); // import the paging classThis statement is no longer needed because the Page Template of version 3.2 is changed to the Think class library.
In general, the Code is not much different from version 3.1 (this is the case in Visual Testing). Let's get my code:
$ Article = M ('Article'); // instantiate a Data Object
$ Count = $ Article-> count (); // The total number of records that meet the query requirements. $ map indicates the query conditions.
$ Page = new \ Think \ Page ($ count, 15); // instantiate the total number of records passed in by the paging class (this is modified according to @ 979137, which is recommended very well !)
$ Show = $ Page-> show (); // display the output by Page
// Query paging data
$ Orderby ['id'] = 'desc ';
$ List = $ Article-> order ($ orderby)-> limit ($ Page-> firstRow. ','. $ Page-> listRows)-> select ();
$ This-> assign ('LIST', $ list); // assign a value to a dataset
$ This-> assign ('page', $ show); // value-assigned paging output
$ This-> display (); // output TemplateIf you change the model in M. Then, the most important thing to note is,
$Page = new \Think\Page($count, 15);This statement, because I have read the code of the Page class, it does not seem to assign an initial value to the number of entries to be displayed on each Page. If you do not input the second parameter "15 ", the Page class does not know the number of entries to be displayed on each Page, so it will not be able to display paging data. Pay attention to this. I just tested it and it can basically be used. If you have any questions in the future, I will try again. Please give me more advice!
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB