public static function findByAttributes($attributes, $condition = null, $params = [])
    {
        if (!is_a($condition, '\\mpf\\datasources\\sql\\ModelCondition'))
            $condition = ModelCondition::getFrom($condition, get_called_class());
        /* @var $condition \mpf\datasources\sql\ModelCondition */
        $oldLimit = $condition->limit;
        $condition->limit = 1;
        $models = static::findAllByAttributes($attributes, $condition, $params);
        $condition->limit = $oldLimit;
        return isset($models[0]) ? $models[0] : null;
    }
public static function findByAttributes($attributes, $condition = null, $params = [])
    {
        if (!is_a($condition, '\\mpf\\datasources\\sql\\ModelCondition'))
            $condition = ModelCondition::getFrom($condition, get_called_class());
        /* @var $condition \mpf\datasources\sql\ModelCondition */
        $oldLimit = $condition->limit;
        $condition->limit = 1;
        $models = static::findAllByAttributes($attributes, $condition, $params);
        $condition->limit = $oldLimit;
        return isset($models[0]) ? $models[0] : null;
    }
public static function findByAttributes ( $ attributes , $ condition = null , $ params = [ ] ) { if ( ! is_a ( $ condition , '\\mpf\\datasources\\sql\\ModelCondition' ) ) $ condition = ModelCondition :: getFrom ( $ condition , get_called_class ( ) ) ; /* @var $condition \mpf\datasources\sql\ModelCondition */ $ oldLimit = $ condition -> limit ; $ condition -> limit = 1 ; $ models = static :: findAllByAttributes ( $ attributes , $ condition , $ params ) ; $ condition -> limit = $ oldLimit ; return isset ( $ models [ 0 ] ) ? $ models [ 0 ] : null ; }
Return a model searched by the selected attributes and optional condition;
@param array $attributes
@param null|string|ModelCondition $condition
@param array $params
@return null|static
Return a model searched by the selected attributes and optional condition ;