thrownewDoctrine_Record_Exception("Unknown property / related component '$name'.");
}
}
}
publicfunctioncoreSetRelated($name,$value){
$rel=$this->_table->getRelation($name);
// one-to-many or one-to-one relation
if($relinstanceofDoctrine_Relation_ForeignKey||
$relinstanceofDoctrine_Relation_LocalKey){
if(!$rel->isOneToOne()){
// one-to-many relation found
if(!($valueinstanceofDoctrine_Collection))
thrownewDoctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references.");
$value->setReference($this,$rel);
}else{
// one-to-one relation found
if(!($valueinstanceofDoctrine_Record))
thrownewDoctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references.");
thrownewDoctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting many-to-many references.");
}
$this->references[$name]=$value;
}
/**
* contains
*
* @param string $name
* @return boolean
*/
publicfunctioncontains($name){
$lower=strtolower($name);
if(isset($this->_data[$lower]))
returntrue;
if(isset($this->_id[$lower]))
returntrue;
if(isset($this->references[$name]))
returntrue;
returnfalse;
}
/**
* @param string $name
* @return void
*/
publicfunction__unset($name){
if(isset($this->_data[$name]))
$this->_data[$name]=array();
// todo: what to do with references ?
}
/**
* applies the changes made to this object into database
* this method is smart enough to know if any changes are made