CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 20999 OCIStmtExecute: ORA-20999: TAPI-1005:Violata chiave esterna STUDENTE_DOCENTE_FK della tabella STUDENTE
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.
return array(
'docente'=>array(self::HAS_MANY, 'studente', 'DOCENTE_MATRICOLA')
);
}
With public function relations()you set the relations, you don’t set the key…
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