mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-22 09:40:41 +08:00
use andWhere() in AR::find() to work properly with default scope
fixes #1469
This commit is contained in:
@@ -67,7 +67,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
{
|
||||
$query = static::createQuery();
|
||||
if (is_array($q)) {
|
||||
if (count($q) == 1 && (array_key_exists(ActiveRecord::PRIMARY_KEY_NAME, $q))) {
|
||||
if (count($q) == 1 && (array_key_exists(ActiveRecord::PRIMARY_KEY_NAME, $q)) && $query->where === null) {
|
||||
$pk = $q[ActiveRecord::PRIMARY_KEY_NAME];
|
||||
if (is_array($pk)) {
|
||||
return static::mget($pk);
|
||||
@@ -75,7 +75,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
return static::get($pk);
|
||||
}
|
||||
}
|
||||
return $query->where($q)->one();
|
||||
return $query->andWhere($q)->one();
|
||||
} elseif ($q !== null) {
|
||||
return static::get($q);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user