protected static function findByCondition($condition)
    {
        $query = static::find();

        if (!ArrayHelper::isAssociative($condition)) {
            // query by primary key
            $primaryKey = static::primaryKey();
            if (isset($primaryKey[0])) {
                // if condition is scalar, search for a single primary key, if it is array, search for multiple primary key values
                $condition = [$primaryKey[0] => is_array($condition) ? array_values($condition) : $condition];
            } else {
                throw new InvalidConfigException('"' . get_called_class() . '" must have a primary key.');
            }
        }

        return $query->andWhere($condition);
    }
protected static function findByCondition($condition)
    {
        $query = static::find();

        if (!ArrayHelper::isAssociative($condition)) {
            
            $primaryKey = static::primaryKey();
            if (isset($primaryKey[0])) {
                
                $condition = [$primaryKey[0] => is_array($condition) ? array_values($condition) : $condition];
            } else {
                throw new InvalidConfigException('"' . get_called_class() . '" must have a primary key.');
            }
        }

        return $query->andWhere($condition);
    }
protected static function findByCondition ( $ condition ) { $ query = static :: find ( ) ; if ( ! ArrayHelper :: isAssociative ( $ condition ) ) { // query by primary key $ primaryKey = static :: primaryKey ( ) ; if ( isset ( $ primaryKey [ 0 ] ) ) { // if condition is scalar, search for a single primary key, if it is array, search for multiple primary key values $ condition = [ $ primaryKey [ 0 ] => is_array ( $ condition ) ? array_values ( $ condition ) : $ condition ] ; } else { throw new InvalidConfigException ( '"' . get_called_class ( ) . '" must have a primary key.' ) ; } } return $ query -> andWhere ( $ condition ) ; }
Finds ActiveRecord instance(s) by the given condition.
This method is internally called by [[findOne()]] and [[findAll()]].
@param mixed $condition please refer to [[findOne()]] for the explanation of this parameter
@return ActiveQueryInterface the newly created [[ActiveQueryInterface|ActiveQuery]] instance.
@throws InvalidConfigException if there is no primary key defined
@internal
Finds ActiveRecord instance ( s ) by the given condition . This method is internally called by [[ findOne () ]] and [[ findAll () ]] .