mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Fixes #15522: Fixed yii\db\ActiveRecord::refresh() method does not use an alias in the condition
This commit is contained in:
committed by
Alexander Makarov
parent
b3130be7ba
commit
1a1fb49426
@ -3,7 +3,7 @@ Yii Framework 2 Change Log
|
||||
|
||||
2.0.14 under development
|
||||
------------------------
|
||||
|
||||
- Bug #15522: Fixed `yii\db\ActiveRecord::refresh()` method does not use an alias in the condition (vladis84)
|
||||
- Enh #15476: Added `\yii\widgets\ActiveForm::$validationStateOn` to be able to specify where to add class for invalid fields (samdark)
|
||||
- Enh #13996: Added `yii\web\View::registerJsVar()` method that allows registering JavaScript variables (Eseperio, samdark)
|
||||
- Enh #9771: Assign hidden input with its own set of HTML options via `$hiddenOptions` in activeFileInput `$options` (HanafiAhmat)
|
||||
|
||||
@ -194,13 +194,17 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
$query = static::find();
|
||||
$tableName = key($query->getTablesUsedInFrom());
|
||||
$pk = [];
|
||||
// disambiguate column names in case ActiveQuery adds a JOIN
|
||||
foreach ($this->getPrimaryKey(true) as $key => $value) {
|
||||
$pk[static::tableName() . '.' . $key] = $value;
|
||||
$pk[$tableName . '.' . $key] = $value;
|
||||
}
|
||||
$query->where($pk);
|
||||
|
||||
/* @var $record BaseActiveRecord */
|
||||
$record = static::findOne($pk);
|
||||
$record = $query->one();
|
||||
return $this->refreshInternal($record);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user