In the source of CActiveFinder.php, line 1321:
if(isset($table->foreignKeys[$fk]))
{
list($tableName,$pk)=$table->foreignKeys[$fk];
if($schema->compareTableNames($pkTable->rawName, $tableName))
$map[$pk]=$fk;
else
throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with a foreign key "{key}" that does not point to the parent table "{table}".',
array('{class}'=>get_class($parent->model), '{relation}'=>$relation->name, '{key}'=>$fk, '{table}'=>$pkTable->name)));
}
This Line:
$schema->compareTableNames($pkTable->rawName, $tableName)
the $pkTable->rawName is : {{table_name}}
but the $tableName is : table_name
When I use a table prefix, so the two value is not equal, and the STAT relation is not functional, an error is reported:
The relation "imagecount" in active record class "scenery" is specified with a foreign key "scenery_id" that does not point to the parent table "{{scenery}}".
Beacuse the code:
list($tableName,$pk)=$table->foreignKeys[$fk];
$tableName has No prefix, It is a bug?
the defination of relation is:
'imagecount' => array(self::STAT, 'simage', 'scenery_id'),