system/classes/Gateway.php
public function count($query)
	{
    // If no partial query was passed in, use data-member db instance.
    if (!isset($query)) {
      $query = $this->db;
    }

    // Clear out any existing SELECT parameters.
    $query->resetSelect();

    // Establish COUNT
    $query->select('COUNT(*)');
    $query->from($this->tableName);

    if ($this->viewQuery) {
      echo $query->getQuery();
    }

    $result = $query->fetch();
    return array_pop($result);
	}
public function count($query)
	{
    // If no partial query was passed in, use data-member db instance.
    if (!isset($query)) {
      $query = $this->db;
    }

    // Clear out any existing SELECT parameters.
    $query->resetSelect();

    // Establish COUNT
    $query->select('COUNT(*)');
    $query->from($this->tableName);

    if ($this->viewQuery) {
      echo $query->getQuery();
    }

    $result = $query->fetch();
    return array_pop($result);
	}
$query is an instance of a Cora database.