phpMyAdmin Designer import to Gii

Would be nice to use phpMyAdmin Designer to create relationships and if Gii could use those in code generation to create relations in code.

You can add comments in your FK and Gii automatically creates relations in your models, like this

[sql]CREATE TABLE Brand (

id smallint(5) unsigned NOT NULL AUTO_INCREMENT,

name varchar(50) NOT NULL,

PRIMARY KEY (id)

);

CREATE TABLE Model (

id smallint(5) unsigned NOT NULL AUTO_INCREMENT,

brandId smallint(5) unsigned NOT NULL COMMENT ‘CONSTRAINT FOREIGN KEY (brandId) REFERENCES Brand(id)’,

name varchar(50) NOT NULL,

PRIMARY KEY (id)

);[/sql]

The second quote doesn’t look like it belong here…

Here. It was part of my signature for half a day (no offense intended). It’s gone.

Now the SQL above is what I use, and Gii makes good use of it. (I learned it from some Yii tutorial, maybe Larry Ullman or the blog tutorial)