src/Db/Orm/ActiveQuery.php
public function scalar($db = null)
    {
        if ($this->emulateExecution) {
            return reject(null);
        }

        return $this->createCommand($db)->then(
            function(CommandInterface $command) {
                return $command->queryScalar();
            }
        );
    }
public function scalar($db = null)
    {
        if ($this->emulateExecution) {
            return reject(null);
        }

        return $this->createCommand($db)->then(
            function(CommandInterface $command) {
                return $command->queryScalar();
            }
        );
    }
Returns the query result as a scalar value.
The value returned will be the first column in the first row of the query results.
@param DatabaseInterface|DbConnectionGetterInterface|null $db the database connection used to generate the SQL statement.
If this parameter is not given, the `db` application component will be used.
@return ExtendedPromiseInterface with string|null the value of the first column in the first row of the query result.
False is returned if the query result is empty.