Bug - gii crud generator

Hullo,

I am using yii-1.1.5.r2654.

I think this is a bug. gii crud generator fails if a column name starts with a number. Found it the hard way. The model generation goes without a problem. Selecting the preview button for crud results in a blank page.

The solution or avoiding this problem is not to use a column name that starts with a number.

I hope this can be fixed in the future versions.

Here is a sample sql script to replicate the problem. Notice the name of the third column 2011AA -

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=‘TRADITIONAL’;

CREATE SCHEMA IF NOT EXISTS ssss DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;

USE ssss ;


– Table ssss.ppp


CREATE TABLE IF NOT EXISTS ssss.ppp (

idPPP INT NOT NULL AUTO_INCREMENT ,

name VARCHAR(50) NULL ,

2011AA BIGINT ZEROFILL NULL ,

PRIMARY KEY (idPPP) ,

UNIQUE INDEX name_UNIQUE (name ASC) )

ENGINE = InnoDB

COMMENT = ‘PPP’;

SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

There is a special section for bug report, I advice you to replicate your post in this section for have better visibility.

Some what on Similar lines if field names contain space in them that to leads to similar error mentioned by you.

Problem is that PHP has some limits about how a variable name can be… for example a variable name cannot start with a number…

As we use variable names to represent table field names… In the new version Gii will test all table fields names… and report these kind of problems…