Hey there.
I am getting trouble with the initialization of an ActiveRecord class. Today I started getting errors of the form:
which turns out to be the attribute assignment directly after the elseif
Xdebug reveals that on that occasion the _attributes property is NULL.
Does anybody know what could be causing this? I've tested it on 1.1.12 and 1.1.13 and it is consistent.
This behavior has surfaced on two distinct models. The only thing they have in common is an interface and a similar relation (they are related to the same model through a many many relation).
I'd love to hear if anybody had something similar happen to them.\
cheers
I am getting trouble with the initialization of an ActiveRecord class. Today I started getting errors of the form:
Cannot use a scalar value as an array (/path/to/framework/CActiveRecord.php:1804)
which turns out to be the attribute assignment directly after the elseif
/**
* Creates an active record with the given attributes.
* This method is internally used by the find methods.
* @param array $attributes attribute values (column name=>column value)
* @param boolean $callAfterFind whether to call {@link afterFind} after the record is populated.
* @return CActiveRecord the newly created active record. The class of the object is the same as the model class.
* Null is returned if the input data is false.
*/
public function populateRecord($attributes,$callAfterFind=true)
{
if($attributes!==false)
{
$record=$this->instantiate($attributes);
$record->setScenario('update');
$record->init();
$md=$record->getMetaData();
foreach($attributes as $name=>$value)
{
if(property_exists($record,$name))
$record->$name=$value;
elseif(isset($md->columns[$name]))
$record->_attributes[$name]=$value;
}
$record->_pk=$record->getPrimaryKey();
$record->attachBehaviors($record->behaviors());
if($callAfterFind)
$record->afterFind();
return $record;
}
else
return null;
}
Xdebug reveals that on that occasion the _attributes property is NULL.
Does anybody know what could be causing this? I've tested it on 1.1.12 and 1.1.13 and it is consistent.
This behavior has surfaced on two distinct models. The only thing they have in common is an interface and a similar relation (they are related to the same model through a many many relation).
I'd love to hear if anybody had something similar happen to them.\
cheers