framework/db/Command.php
public function queryScalar()
    {
        $result = $this->queryInternal('fetchColumn', 0);
        if (is_resource($result) && get_resource_type($result) === 'stream') {
            return stream_get_contents($result);
        }

        return $result;
    }
public function queryScalar()
    {
        $result = $this->queryInternal('fetchColumn', 0);
        if (is_resource($result) && get_resource_type($result) === 'stream') {
            return stream_get_contents($result);
        }

        return $result;
    }
Executes the SQL statement and returns the value of the first column in the first row of data.
This method is best used when only a single value is needed for a query.
@return string|null|false the value of the first column in the first row of the query result.
False is returned if there is no value.
@throws Exception execution failed