public function runQueryForObject($connection, $command, &$result)
{
$object = null;
$connection->setActive(true);
foreach ($command->query() as $row) {
$object = $this->applyResultMap($row, $result);
}
if (!$this->_groupBy->isEmpty()) {
$list = $this->_groupBy->collect();
$this->initialGroupByResults();
$object = $list[0];
}
$this->executePostSelect($connection);
$this->onExecuteQuery($command);
return $object;
}