/** * Executes a query on the database system. * @param \System\Db\Query The query to be executed * @return \System\Db\DatabaseResult A collection of result from the database. */ public function query(\System\Db\Query $query) { if ($query->getUseSecondaryPipe() && $this->secondaryPipe instanceof \System\Db\Database) { $query->setUseSecondaryPipe(false); return $this->secondaryPipe->query($query); } else { $result = null; //we increase the amount of db queries $this->dbQueryCount++; $result = new DatabaseResult($this->httpTunnel, $this->createPostString(self::MODE_QUERY), $query, $this); $event = new \System\Event\Event\OnMySQLQueryEvent(); $event->setQuery($query); $event->setResult($result); $event->raise($this); return $result; } }