Welcome Guest, Not a member yet? Register   Sign In
Using the built-in pagination functions
#2

The Model::paginate() method uses the Model and QueryBuilder methods to retrieve data.
PHP Code:
$model = new \App\Models\UserModel();
$model->paginate(10); // calls inside $model->findAll(10); 
To add selection criteria
PHP Code:
$model->where('a''b')->paginate(10); 

You can move the conditions to a separate method.
PHP Code:
//model
public function myConditions($a)
{
    
$this->builder()->where('a'$a);
    return 
$this;
}

$model->myConditions($a)->paginate(10); 

Using $this->db->query() immediately executes the query and cannot be used with the Model::paginate() method.
Reply


Messages In This Thread
RE: Using the built-in pagination functions - by iRedds - 01-20-2022, 07:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB