2010/3/23 Hetényi Csaba <[email protected]>:
>   my $rs = $c->model('DB::Users')->search(
>       {
>           nem => $nem,
>           megye => $megye,
>       },
>   );
>
>
> BUT, if the user wants to see all of the rows (but the 'nem' clause still
> applied) what have to put in
> $megye?
> (i tried "LIKE", "%" things but it is for text type)
> Is there a way to ignore "megye => $megye" line completely in this case, but
> remain other clauses in
> search ?
>
> In old times (before Catalyst) i have builded a custom sql statement for
> every user request with string-based operations:
>
> $sql="SELECT * FROM users WHERE nem = $nem";
> $sql = "$sql AND megye = $megye" if $megye != 0;

my $search_clause = { nem => $nem };
if ( $megye ) { $search_clause->{megye} = $megye; }

my $rs = $c->model('Users')->search( $search_clause );

It's just a hashref.

Rob

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to