Cake\ORM\Query::counter PHP Method

counter() public method

This is particularly useful when you need to optimize a query for returning the count, for example removing unnecessary joins, removing group by or just return an estimated number of rows. The callback will receive as first argument a clone of this query and not this query itself. If the first param is a null value, the built-in counter function will be called instead
public counter ( callable | null $counter )
$counter callable | null The counter value
    public function counter($counter)
    {
        $this->_counter = $counter;
        return $this;
    }