That happens when I try to play around with DB::select instead of ORM. The query is returned as an object, but the error appears.
Code:
$bd_userdata -> offset($pagination -> offset) -> limit($pagination -> items_per_page) -> find_all() -> as_array();
Error:
ErrorException [ Fatal Error ]: Call to undefined method Database_MySQL_Result::offset()
Does it mean I have to count rows, before I send them to the offset in pagination?
When I try $query->count_all()
I get the error message:
Undefined property: Database_Query_Builder_Select::$count_all
I tried count($query)
but instead I got:
No tables used [ SELECT * LIMIT 4 OFFSET 0 ]
Here is the solution:
$results = DB::select('*')
->from('users')
->where('id', '=', 1)
->limit($pagination->items_per_page)
->offset($pagination->offset)->execute();
And a counter:
$count = $results->count_all();
I was doing it before, the other way around. That is why it did not work.