Regarding the problem of repeatedly executing sql
麦子
麦子 2021-11-28 20:34:05
0
4
1068

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.

麦子
麦子

reply all(2)
demo

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

  • reply 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~
    麦子 author 2021-11-29 21:49:51
demo

Yes, it just depends on how you like to use it

  • reply Boss, please write a code explanation.
    麦子 author 2021-11-29 10:49:37
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template