Is There A Way To Check Referential Integrity For Myisam Tables Using Yii

While I used InnoDB tables I caught FK constraint exceptions from InnoDB engine.

I know that Yii can fetch related tables according to relations(). Besides I need to check referential integrity during other CRUD operations - such as insert, update and delete.

Is there some Yii native mechanism to perform this? Or I should write additional code for this checking?

I’m not aware of such a mechanism. You can implement this in the app level. Possibly devise some “super class” for active record classes and in it implement this via the after* and before* hooks (and more). You can also develop this as ‘behaviors’ and attach those to the active record classes. You have many options for this… .

But I’m not sure - if you do need referential integrity, why NOT use InnoDB? You can indeed catch the exceptions and examine their error code (what came from your MySQL server) and act accordingly.

Tnx, I’ve already implemented this using hooks.

/* Moved to General Discussion */

(not a tip, snippet or tutorial)