Yii Framework Forum: FOREIGN KEY - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

FOREIGN KEY Rate Topic: -----

#1 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 28 April 2010 - 03:38 AM

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')

);
}
This is in the model studente
-1

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,367
  • Joined: 12-October 09
  • Location:Croatia

Posted 28 April 2010 - 04:13 AM

Why are you opening a new thread for the exact same error as in another thread of yours

http://www.yiiframew.../8924-error-db/
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 28 April 2010 - 04:19 AM

View Postmdomba, on 28 April 2010 - 04:13 AM, said:

Why are you opening a new thread for the exact same error as in another thread of yours

http://www.yiiframew.../8924-error-db/


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
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,367
  • Joined: 12-October 09
  • Location:Croatia

Posted 28 April 2010 - 04:22 AM

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
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users