I recently had to change a database table to have 2 primary keys / auto-incrementing columns. Now, when I run a self::STAT on two tables, I get the following error:
The relation "rantCount" in active record class "Topic" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "Topic".
The "Topic" table has 2 primary keys. The two tables at issue are related by only 1 primary key from the "Topic" table.
How can I fix this problem?
Er… what? By any chance: You don’t mean a composite primary key, don’t you?
No, it is not a composite primary key. There is a primary unique key - topicId, and then there is another int field that will always be unique. The only way to get it that field to auto-increment is to set it as a primary key. I’m using Myisam db engine.
Any assistance would be appreciated.
I’m mighty confused. And I can imagine Yii’s db-logic might be confused as well. Maybe you could paste the output of SHOW CREATE TABLE
topic ? If you’ve really got multiple primary keys (which would make me die a little inside), Yii might only see one of them. If it’s a composite primary key, the STAT-relation would most likely miss a column.