Closed
Description
Sometime, we need to generate just of count all results after getting limited records for pagination. Is it possible to add 3rd parameter in find all function in modeling data and update it like below. code which is working fine, or provide a function to set reset function at model level, so it can be done on/off as required.
/**
* Works with the current Query Builder instance to return
* all results, while optionally limiting them.
*
* @param integer $limit
* @param integer $offset
* @param boolean $reset
*
* @return array
*/
public function findAll(int $limit = 0, int $offset = 0,$reset = true)
{
$builder = $this->builder();
if ($this->tempUseSoftDeletes === true)
{
$builder->where($this->table . '.' . $this->deletedField, null);
}
$row = $builder->get($limit, $offset,$reset);
$row = $row->getResult($this->tempReturnType);
$eventData = $this->trigger('afterFind', ['data' => $row, 'limit' => $limit, 'offset' => $offset]);
$this->tempReturnType = $this->returnType;
$this->tempUseSoftDeletes = $this->useSoftDeletes;
return $eventData['data'];
}
Many thanks for making Codeigniter 4 in good shape.
Metadata
Metadata
Assignees
Labels
No labels
Activity