Yii 1.1.14 on debian
When looking for a model with findByPk() combining with an alias in defaultScope() and resetScope(), sql breaks with:
Column not found: 1054 Unknown column 't.id' in 'where clause'
.
The SQL statement executed was:
SELECT * FROM `tbl` `my_alias` WHERE `t`.`id`='25' LIMIT 1"
Code :
public function defaultScope()
{
return array(
'alias'=>'my_alias',
'condition'=>"my_alias.somefield= something",
'order'=>'my_alias.name',
);
}
And
$model = MyModel::model()->resetScope()->findByPk($id); // breaks
$model = MyModel::model()->findByPk($id); // ok
To sum up alias is not reseted with resetScope() and findByPk use the alias : t
.
In 1.1.13 everything works well.