public static function getByAttribute($attribute, $value, $asArray = false)
    {
        if (isset(self::$uniqueAttributeToId[$attribute][$value])) {
            return static::getById(self::$uniqueAttributeToId[$attribute][$value], $asArray);
        }
        $row = static::find()
            ->where([$attribute => $value])
            ->asArray($asArray)
            ->one();
        static::addRowToMap($row);
        return $row;
    }
public static function getByAttribute($attribute, $value, $asArray = false)
    {
        if (isset(self::$uniqueAttributeToId[$attribute][$value])) {
            return static::getById(self::$uniqueAttributeToId[$attribute][$value], $asArray);
        }
        $row = static::find()
            ->where([$attribute => $value])
            ->asArray($asArray)
            ->one();
        static::addRowToMap($row);
        return $row;
    }
public static function getByAttribute ( $ attribute , $ value , $ asArray = false ) { if ( isset ( self :: $ uniqueAttributeToId [ $ attribute ] [ $ value ] ) ) { return static :: getById ( self :: $ uniqueAttributeToId [ $ attribute ] [ $ value ] , $ asArray ) ; } $ row = static :: find ( ) -> where ( [ $ attribute => $ value ] ) -> asArray ( $ asArray ) -> one ( ) ; static :: addRowToMap ( $ row ) ; return $ row ; }
Get a single record by unique attribute
@param string $attribute
@param mixed $value
@param bool $asArray
@return array|null|ActiveRecord
Get a single record by unique attribute