Commit 4a9f47be by Carsten Brandt

refactored sphinx and db AR to call parent implementation of populateRecord()

parent 16e1aff4
......@@ -623,20 +623,13 @@ abstract class ActiveRecord extends BaseActiveRecord
*/
public static function populateRecord($record, $row)
{
// TODO refactor to call parent
$columns = static::getIndexSchema()->columns;
foreach ($row as $name => $value) {
if (isset($columns[$name])) {
$column = $columns[$name];
if ($column->isMva) {
$value = explode(',', $value);
}
$record->setAttribute($name, $value);
} else {
$record->$name = $value;
if (isset($columns[$name]) && $columns[$name]->isMva) {
$row[$name] = explode(',', $value);
}
}
$record->setOldAttributes($record->getAttributes());
parent::populateRecord($record, $row);
}
/**
......
......@@ -279,20 +279,13 @@ class ActiveRecord extends BaseActiveRecord
*/
public static function populateRecord($record, $row)
{
// TODO refactor to call parent
$attributes = array_flip($record->attributes());
$columns = static::getTableSchema()->columns;
foreach ($row as $name => $value) {
if (isset($columns[$name])) {
$value = $columns[$name]->typecast($value);
}
if (isset($attributes[$name])) {
$record->setAttribute($name, $value);
} else {
$record->$name = $value;
$row[$name] = $columns[$name]->typecast($value);
}
}
$record->setOldAttributes($record->getAttributes());
parent::populateRecord($record, $row);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment