Yii Framework Forum: page 198 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

page 198

#1 User is offline   fonis 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 22-March 12

Posted 02 June 2012 - 06:42 AM

hey guys, i've run into a problem. at page 198 i had to fill in the tbl_project_user_role and thereafter change the testIsInRole(). The problem is when i run the test, i get this error:

1) ProjectTest::testDelete
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`trackstar_test`.`tbl_project_user_role`, CONSTRAINT `tbl_project_user_role_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `tbl_project` (`id`))

i then see this problem is a solved issue at this forum, but i don't understand the solution:

Informational Note: Page 198 -
You might need to define the foreign key relationship on tbl_project_user_role.project_id to automatically handle deletes of rows in the project table. Otherwise, you might get a constraint violation error when the unit test ProjectTest::testDelete() is run.
in MySQL, something like

can anyone please help me understand that solution?

#2 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 515
  • Joined: 08-August 09

Posted 03 June 2012 - 12:09 AM

I suppose you may want to start with MySQL Foreign Keys docs if such a question arises.

In a case you're familiar with mysql foreign keys and its declaration, then what exactly is unclear?

#3 User is offline   sosdios 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-June 12

Posted 07 June 2012 - 01:35 PM

If you want a quick tutorial on foreign keys and how to understand their constraints and errors, check out this white paper: www.eliacom.com/wpForeignKeys.php
Let me know if you have any additional questions and I can hopefully answer anything you still aren't understanding.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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