page 198

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

ON DELETE CASCADE ON UPDATE CASCADE

can anyone please help me understand that solution?

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?

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.