我可以从工具包模板文件中搜索结果集吗?
我使用 Catalyst 并将结果集放入存储中以供 TT 访问:
$c->stash->{tournament} = $c->model('DB::Tournament')->find($id);
该类与“tournament_participant”有关系,我从 TT 页面内部访问它,如下所示:
[% FOREACH participant IN tournament.tournament_participants -%]
问题是,我想按如下列对结果进行排序:
[% FOREACH participant IN tournament.tournament_participants.search( {}, { sort_by => 'position' } ) -%]
但上面的方法不起作用(没有返回任何内容)。这可以吗?
I use Catalyst and put a resultset into the stash for TT to access:
$c->stash->{tournament} = $c->model('DB::Tournament')->find($id);
This class has a relationship with "tournament_participant" which I access from inside a TT page like this:
[% FOREACH participant IN tournament.tournament_participants -%]
problem is, I want to sort the result by a column like this:
[% FOREACH participant IN tournament.tournament_participants.search( {}, { sort_by => 'position' } ) -%]
but the above does not work (nothing is returned). Is this possible to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以解决问题(假设关系确实是
tournament_participants
(这看起来有点多余和笨拙;tournament.participants
感觉更自然,并且很容易在结果类中更改)如果需要)–文档:DBIx::Class: :关系::基础。
This should do the trick (assuming the relationship really is
tournament_participants
(which seems a little redundant and ungainly;tournament.participants
feels more natural and is easy to change in the result class if desired)–Doc: DBIx::Class::Relationship::Base.