Dear Members

I look for info about in subject.

I have a table, which has an integer data-type column (in the example: megye). I'd like to search for specific value (for ex.: nem = 1, megye = 5) and it works perfectly
with the following code :

   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;
..
.
but i hope there is a nicer way!
(I readed SQL::Abstract but not find the solution)


Thank You in advance!
Csabi

_______________________________________________
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