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 ...@@ -623,20 +623,13 @@ abstract class ActiveRecord extends BaseActiveRecord
*/ */
public static function populateRecord($record, $row) public static function populateRecord($record, $row)
{ {
// TODO refactor to call parent
$columns = static::getIndexSchema()->columns; $columns = static::getIndexSchema()->columns;
foreach ($row as $name => $value) { foreach ($row as $name => $value) {
if (isset($columns[$name])) { if (isset($columns[$name]) && $columns[$name]->isMva) {
$column = $columns[$name]; $row[$name] = explode(',', $value);
if ($column->isMva) {
$value = explode(',', $value);
}
$record->setAttribute($name, $value);
} else {
$record->$name = $value;
} }
} }
$record->setOldAttributes($record->getAttributes()); parent::populateRecord($record, $row);
} }
/** /**
......
...@@ -279,20 +279,13 @@ class ActiveRecord extends BaseActiveRecord ...@@ -279,20 +279,13 @@ class ActiveRecord extends BaseActiveRecord
*/ */
public static function populateRecord($record, $row) public static function populateRecord($record, $row)
{ {
// TODO refactor to call parent
$attributes = array_flip($record->attributes());
$columns = static::getTableSchema()->columns; $columns = static::getTableSchema()->columns;
foreach ($row as $name => $value) { foreach ($row as $name => $value) {
if (isset($columns[$name])) { if (isset($columns[$name])) {
$value = $columns[$name]->typecast($value); $row[$name] = $columns[$name]->typecast($value);
}
if (isset($attributes[$name])) {
$record->setAttribute($name, $value);
} else {
$record->$name = $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