public function queryScalar()
{
try {
// Prado::trace('Query Scalar: '.$this->getDebugStatementText(), 'Prado\Data');
if ($this->_statement instanceof PDOStatement) {
$this->_statement->execute();
} else {
$this->_statement = $this->getConnection()->getPdoInstance()->query($this->getText());
}
$result = $this->_statement->fetchColumn();
$this->_statement->closeCursor();
if (is_resource($result) && get_resource_type($result) === 'stream') {
return stream_get_contents($result);
} else {
return $result;
}
} catch (Exception $e) {
throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText());
}
}