Posted 28 April 2010 - 03:38 AM
HOW CAN I SET FOREIGN KEY?
I have tried
public function relations()
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
'docente'=>array(self::HAS_MANY, 'studente', 'DOCENTE_MATRICOLA')
This is in the model studente
Posted 28 April 2010 - 04:19 AM
Yes i do but now don't work!!!I have always the same error..
The table have other foreign key...i don't understand if i set all keys not only one
Posted 28 April 2010 - 04:22 AM
the error means that you are inserting a record for the table STUDENTE with a value for STUDENTE.DOCENTE_ID that does not exist in the table DOCENTE
the foreign key you have to set by means of user input or by adding in your code something like $model->docente_id = 3 (where 3 is ID of DOCENTE that DOES EXIST in the DOCENTE table)
hope you understand...
P.S. please don't open new threads for already discussed problems (comment on existing one) because this way we clobber the forum... and is more useful for later reading if one problem is discussed in one thread