CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

Pagination library cast total_rows to int

Open aanbar opened this issue 13 years ago • 2 comments

On line 357 the check fails sometimes.

if ($this->total_rows === 0 OR $this->per_page === 0)

should be switched to this

if ( (int) $this->total_rows === 0 OR  (int) $this->per_page === 0)

I haven't looked into the full source code of the library, but if these variables can be transformed elsewhere it would be a better idea.

aanbar avatar Oct 07 '13 16:10 aanbar

This line is intended to check if you've got the default values, which are integers and don't need typecasting. Do you have a more specific case that needs that proposed change?

narfbg avatar Oct 08 '13 09:10 narfbg

MySQL returns count as string, so if you're on some page (already going through pagination) then you empty the table you'll still see the "first page" link returned instead of nothing.

aanbar avatar Oct 08 '13 10:10 aanbar