Hi everyone,
how do you populate a model with data from different rows without having to instantiate a new model for every row?
I need to do this because i just want to validate data i read from a file and instantiating a new model for every row is not very efficient.
I basically want to validate and insert/update a bunch of rows i read from a csv file using just 1 instance of a model. This is what i have in my model.
public function reloadAttributes($attributes = false) {
$this->clearErrors();
$this->_pk = null;
if($attributes !== false) {
$this->setScenario('update');
$this->setIsNewRecord(false);
$this->setAttributes($attributes, false);
}
else {
$this->setScenario('insert');
$this->setIsNewRecord(true);
$this->setAttributes($this->getMetaData()->attributeDefaults, false);
}
}