yii\redis\ActiveQuery::scalar PHP 메소드

scalar() 공개 메소드

The value returned will be the specified attribute in the first record of the query results.
public scalar ( string $attribute, Connection $db = null ) : string
$attribute string name of the attribute to select
$db Connection the database connection used to execute the query. If this parameter is not given, the `db` application component will be used.
리턴 string the value of the specified attribute in the first record of the query result. Null is returned if the query result is empty.
    public function scalar($attribute, $db = null)
    {
        $record = $this->one($db);
        if ($record !== null) {
            return $record->hasAttribute($attribute) ? $record->{$attribute} : null;
        } else {
            return null;
        }
    }