Findbypk And Alias (1.1.14)

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 '' 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(


  'condition'=>"my_alias.somefield= something",





$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.

Thanks for reporting, created an issue on github: