[closed]Migration problem

Yii sceleton app on Production when running here




$criteria = new CDbCriteria;

		

$sort = new CSort('user');

$sort->attributes = array(

'user.username'=>'username',

'user.group_id'=>'group_id',

'user.email'=>'email',

'user.created'=>'created',

'user.email_confirmed'=>'email_confirmed',

);


$sort->defaultOrder = 'user.created DESC';//<<<<<<<<<

$sort->applyOrder($criteria);

//$criteria->select='COUNT(post.id) AS NumComments';

$users=User::model()->with('group', 'num_posts')->findAll($criteria);



[sql]SELECT t.id AS t0_c0,

     `t`.`username`        AS `t0_c1`,


     `t`.`password`        AS `t0_c2`,


     `t`.`email`           AS `t0_c3`,


     `t`.`email_visible`   AS `t0_c4`,


     `t`.`notify_comments` AS `t0_c5`,


     `t`.`notify_messages` AS `t0_c6`,


     `t`.`about`           AS `t0_c7`,


     `t`.`aboutparsed`     AS `t0_c8`,


     `t`.`group_id`        AS `t0_c9`,


     `t`.`email_confirmed` AS `t0_c10`,


     `t`.`created`         AS `t0_c11`,


     `t`.`modified`        AS `t0_c12`,


     `group`.`id`          AS `t1_c0`,


     `group`.`name`        AS `t1_c1`,


     `group`.`created`     AS `t1_c2`,


     `group`.`modified`    AS `t1_c3`

FROM user t

     LEFT OUTER JOIN `group` `group`


       ON (`t`.`group_id` = `group`.`id`)

ORDER BY user.created DESC #//<<<<<<<<<

LIMIT 25[/sql]

Raises


SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.created' in 'order clause'

Meanwhile in Dev environment (Win+WAMP) everything works fine.

What is the problem?

Check case sensitive of table`s names imported to new database.

chagne ‘user.’ to ‘t.’

mysqld @Prod behaviors like mysqld @Dev (both are lowercased).

on Dev yiis ar generate

[sql]

SELECT user.id AS t0_c0,

   `user`.`username`        AS `t0_c1`,


   `user`.`password`        AS `t0_c2`,


   `user`.`email`           AS `t0_c3`,


   `user`.`email_visible`   AS `t0_c4`,


   `user`.`notify_comments` AS `t0_c5`,


   `user`.`notify_messages` AS `t0_c6`,


   `user`.`about`           AS `t0_c7`,


   `user`.`aboutparsed`     AS `t0_c8`,


   `user`.`group_id`        AS `t0_c9`,


   `user`.`email_confirmed` AS `t0_c10`,


   `user`.`created`         AS `t0_c11`,


   `user`.`modified`        AS `t0_c12`,


   `group`.`id`             AS `t1_c0`,


   `group`.`name`           AS `t1_c1`,


   `group`.`created`        AS `t1_c2`,


   `group`.`modified`       AS `t1_c3`

FROM user

   LEFT OUTER JOIN `group` `group`


     ON (`user`.`group_id` = `group`.`id`)

LIMIT 25

[/sql]

the same query on Prod

[sql]

SELECT t.id AS t0_c0,

   `t`.`username`        AS `t0_c1`,


   `t`.`password`        AS `t0_c2`,


   `t`.`email`           AS `t0_c3`,


   `t`.`email_visible`   AS `t0_c4`,


   `t`.`notify_comments` AS `t0_c5`,


   `t`.`notify_messages` AS `t0_c6`,


   `t`.`about`           AS `t0_c7`,


   `t`.`aboutparsed`     AS `t0_c8`,


   `t`.`group_id`        AS `t0_c9`,


   `t`.`email_confirmed` AS `t0_c10`,


   `t`.`created`         AS `t0_c11`,


   `t`.`modified`        AS `t0_c12`,


   `group`.`id`          AS `t1_c0`,


   `group`.`name`        AS `t1_c1`,


   `group`.`created`     AS `t1_c2`,


   `group`.`modified`    AS `t1_c3`

FROM user t

   LEFT OUTER JOIN `group` `group`


     ON (`t`.`group_id` = `group`.`id`)

LIMIT 25

[/sql]

‘user’ table is somehow converted to ‘t’. how can i avoid this behavior?

upd.

this answer http://www.yiiframework.com/forum/index.php?/topic/6510-column-not-found-1054-unknown-column-usercreated-in-order-clause/page__view__findpost__p__33353 position problem (conversion ‘user’ to ‘t’) as yii 1.1-nightly behavior.

what is the better solution: use 1.1rc or use some dog-nails to prevent ‘user’ to ‘t’ conversion?

problem resolved