我有一个 SQL 查询,它从 sqlplus 获取数据更正。当我尝试转换查询以便可以在催化剂控制器中实现时,我收到一条错误消息,指出表 Feature 和 Featurealias 之间没有关系。由于我是 Catalyst 和 DBIx::Class 的新手,所以我不是能够弄清楚可能是什么错误。任何机构都可以帮我解决这个问题。下面是我试图在催化剂控制器中实现的 SQL 查询和代码。
my@sourceid=$c->model('Gene::Featurealias')->search({
'feature.typeid'=>4,
},
{
join=>'feature',
distinct=>1,
columns=>[qw/sourceid/]
});
SQL查询:
select distinct FeatureAlias.SourceID From FeatureAlias join Feature on FeatureAlias.FeatureID=Feature.FeatureID where Feature.TypeID=4;
在 Feature.pm 中定义
__PACKAGE__->has_many( "featurealias",
"...Result::Featurealias");
在 Featurealias.pm 中定义
__PACKAGE__->belongs_to("featureid",
"...::Result::Feature");
提前致谢。