Gii and Relations among InnoDB tables

Hi guys, i just started to try this framework, and while i really like it so far, i’m having a couple of problems.

i’m having some problems figuring out why gii isn’t generating by default the relations in the model.

here are two of my tables:


CREATE TABLE `azienda` (

  `id` bigint(20) NOT NULL AUTO_INCREMENT,

  `version` bigint(20) NOT NULL,

  `comune_id` bigint(20) NOT NULL,

  `data_creazione` datetime NOT NULL,

  `edificio` varchar(255) NOT NULL,

  `email` varchar(255) NOT NULL,

  `ente_id` bigint(20) NOT NULL,

  `fax` varchar(255) NOT NULL,

  `fisso` varchar(255) NOT NULL,

  `interno` varchar(255) NOT NULL,

  `nome` varchar(255) NOT NULL,

  `numero` varchar(255) NOT NULL,

  `partita_iva` varchar(255) NOT NULL,

  `ragione_sociale` varchar(255) NOT NULL,

  `scala` varchar(255) NOT NULL,

  `settore` varchar(255) NOT NULL,

  `tipologia_azienda_id` bigint(20) NOT NULL,

  `via` varchar(255) NOT NULL,

  PRIMARY KEY (`id`),

  KEY `FKE162E636A396593A` (`tipologia_azienda_id`),

  KEY `FKE162E636A13D7F9A` (`ente_id`),

  KEY `FKE162E6362DA945FA` (`comune_id`),

  CONSTRAINT `FKE162E6362DA945FA` FOREIGN KEY (`comune_id`) REFERENCES `comune` (`id`),

  CONSTRAINT `FKE162E636A13D7F9A` FOREIGN KEY (`ente_id`) REFERENCES `ente` (`id`),

  CONSTRAINT `FKE162E636A396593A` FOREIGN KEY (`tipologia_azienda_id`) REFERENCES `tipologia_azienda` (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;


CREATE TABLE `ente` (

  `id` bigint(20) NOT NULL AUTO_INCREMENT,

  `version` bigint(20) NOT NULL,

  `data_creazione` datetime NOT NULL,

  `edificio` varchar(255) NOT NULL,

  `email` varchar(255) NOT NULL,

  `fax` varchar(255) NOT NULL,

  `fisso` varchar(255) NOT NULL,

  `interno` varchar(255) NOT NULL,

  `nome` varchar(255) NOT NULL,

  `numero` varchar(255) NOT NULL,

  `scala` varchar(255) NOT NULL,

  `settore` varchar(255) NOT NULL,

  `via` varchar(255) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

when I generate the models with gii all i get are empty relations methods.

Another question, in the generating model view of gii if i input a * for the table name I get a list of only the tables with a tbl_ prefix.

I thought it depended from my db configuration in the main.php file, so i changed it and i took off the tablePrefix key from the array, but still all i get are those tables.

There is also someway to generate all the CRUD for all the models with just one click? the * wild card doesn’t work in the generate crud view of gii.

thanks a lot for your help :D

problem solved.

Gii checks relations among tables with the same prefix.

To make it work i just had to put no prefix in the Gii model generation form.