/**
  * Return the number of result rows.
  * @return integer
  */
 public function countResults()
 {
     $ds = $this->template->getSection("datasource");
     if (!isset($ds["countmode"]) || in_array($ds["countmode"], array("false", "none", "null"))) {
         return;
     }
     if ($this->connection != "icinga") {
         $this->getContext()->getModel("DBALMetaManager", "Api")->switchIcingaDatabase($this->connection);
     }
     return $this->query->count();
 }