CDbCommand无法执行SQL语句:SQLSTATE [42S22]:找不到列:1054'order子句'中的未知列'update_time'。
执行的SQL语句是:
SELECT `t`.`id` AS `t0_c0`,
`t`.`title` AS `t0_c1`,
`t`.`content` AS `t0_c2`,
`t`.`status` AS `t0_c3`,
`t`.`tags` AS `t0_c4`,
`t`.` update_time` AS `t0_c5`,
`t`.`create_time` AS `t0_c6`,
`t`.`author_id` AS `t0_c7`
FROM `post` `t`
WHERE (status=2)
ORDER BY update_time DESC
LIMIT 10
答案 0 :(得分:0)
尝试通过它的别名引用该列:
SELECT `t`.`id` AS `t0_c0`,
`t`.`title` AS `t0_c1`,
`t`.`content` AS `t0_c2`,
`t`.`status` AS `t0_c3`,
`t`.`tags` AS `t0_c4`,
`t`.`update_time` AS `t0_c5`,
`t`.`create_time` AS `t0_c6`,
`t`.`author_id` AS `t0_c7`
FROM `post` `t`
WHERE (`t`.`status`=2)
ORDER BY `t`.`update_time` DESC
LIMIT 10
答案 1 :(得分:0)
您需要使用列名称指定表名本身,就像
一样 WHERE (t.status=2) //replace this line in your code
ORDER BY t.update_time DESC //replace this line in your code