在分页的最后一页之后如何强制推进返回Null?

时间:2022-10-20 10:46:43

I use Propel to get result from MySQL and use paginate.

我使用Propel从MySQL获得结果并使用paginate。

When for a result that have for example 100 rows and I use

当对于具有例如100行的结果并且我使用时

->paginate(6, 20);

it must return NULL because we past the last page but it returns content of the last page even I use paginate(10000, 20)!!!!

它必须返回NULL,因为我们经过最后一页,但它返回最后一页的内容,即使我使用paginate(10000,20)!

In the other word how can I understand I passed the last page if I can not force it to return NULL for pages after last page?

换句话说,如果我不能强迫它在最后一页之后为页面返回NULL,我怎么能理解我通过了最后一页呢?

1 个解决方案

#1


Actually you can count the number of total elements by a simple count() function and then calculate how many page you have and what is your last page.

实际上,您可以通过简单的count()函数计算总元素数,然后计算您拥有的页数以及最后一页。

If you go inside of the php files of propel you would see that when the result is empty it feeds the last page as the result and returns it back.

如果你进入推文的php文件,你会看到当结果为空时,它会将最后一页作为结果反馈并返回。

I don't think that you have any other option.

我不认为你有任何其他选择。

#1


Actually you can count the number of total elements by a simple count() function and then calculate how many page you have and what is your last page.

实际上,您可以通过简单的count()函数计算总元素数,然后计算您拥有的页数以及最后一页。

If you go inside of the php files of propel you would see that when the result is empty it feeds the last page as the result and returns it back.

如果你进入推文的php文件,你会看到当结果为空时,它会将最后一页作为结果反馈并返回。

I don't think that you have any other option.

我不认为你有任何其他选择。