Gii/giix Handles Exceptions In Database?

Hi!!

I have built my web application from Gii / Giix and all the model database successfully, except one!

That is because the Foreign Keys relation is as Restrict.

And for that reason shows up an uncontrolled error (exception):

[i]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 (andrea_fast.day_language, CONSTRAINT fk_day_language_2 FOREIGN KEY (code_language) REFERENCES language (code) ON UPDATE CASCADE). The SQL statement executed was: DELETE FROM language WHERE language.code=‘en-US’

[/i]

¿Do I something wrong? ¿Or does this mean that Yii does not control these exceptions?

If anyone can guide me…

Thank in advance!

Totto, you’re trying to delete a language entry that’s being used by an entry in another table. The data is linked via a foreign key constraint, which doesn’t allow you to remove it.

This behavior is probably what you want to avoid the loss of data (by avoiding the removal of the referenced data).

I recommend that you either handle the exception or remove the related entries manually.

Thanks Rodrigo!

Of your proposals I choose "handle the exception".

But, you have any idea how could I control that?

I ignore whether there is a format to control the exceptions.

http://php.net/exceptions