Db:table('shop_goods')->count();
Here I executed one more Db query to query the total number of paging. I feel that the query efficiency is affected. Can I compare it with the query data set results? Share one? Just execute Db:table('shop_goods') once.
2 answers
Didn’t you take out the result set directly? Check the length of the result set directly, and then divide it by how many pages are divided into. Once divided, the number of pages will come out. If it’s troublesome for you, just use the method provided by tp
Yes, but if the result set is conditionally filtered, for example, there are 10 pieces of data in total, and there are only 3 pieces after filtering, then the length of the output result set is 3, which is wrong~
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20416
7
13576
4






