PK typecast at yii\db\ActiveRecord restored

This commit is contained in:
Klimov Paul
2015-04-14 12:00:22 +03:00
parent 60aa5f3eb9
commit b05ea3d69e

View File

@@ -457,8 +457,14 @@ class ActiveRecord extends BaseActiveRecord
if (($primaryKeys = static::getDb()->schema->insert($this->tableName(), $values)) === false) {
return false;
}
$this->setAttributes($primaryKeys, false);
$values = array_merge($values, $primaryKeys);
foreach ($primaryKeys as $name => $value) {
if ($this->getAttribute($name) === null) {
$id = $this->getTableSchema()->columns[$name]->phpTypecast($value);
$this->setAttribute($name, $id);
$values[$name] = $id;
break;
}
}
$changedAttributes = array_fill_keys(array_keys($values), null);
$this->setOldAttributes($values);