我在 SQLite 数据库中有一个表,并且我有一个名为 Account 的模式。我还有一个搜索用户的表单。在我的控制器中,我这样做:
my $params ||= $c->req->parameters; # Don't know what the difference is between ||= and =, did that way because someone had done it to and it works
my $search_term = $params->{search};
if( $c->request->params{submit} )
{
$c->stash->{search_term} = $search_term;
$c->stash->{search_results} = $c->model("DB::Account")->find({
firstname => { like => "%$search_term%" },
}) if $c->stash->{search_term};
}
然后在我看来,我有这样的事情。
[% IF search_results > 0 %]
[% FOREACH results IN search_results %]
[% results.email %] <br/>
[% results.firstname %]
[% END %]
上面的代码工作正常。我想要做的是搜索与 或其他列匹配的表firstname
,lastname
而不仅仅是一列。
我对 Catalyst 框架和 Perl 相当陌生(用 perl 做过一些事情,但不是很先进),所以任何帮助和提示将不胜感激。