in reply to Trying to build a where clause to insert into a DBIx::Class Query
Hi, try this:
Output:use strict; use warnings; use feature 'say'; use SQL::Abstract; my $input = 'Orlando Miguel Jose Fernando'; my @match = map { +{ 'like' => qq{'%$_%'} } } split ' ', $input; my %where = ( Name => [ -and => @match ] ); my $sqla = SQL::Abstract->new; my ($sql, @bind) = $sqla->select('People', undef, \%where); say $sql; say for @bind; __END__
$ perl 1208017.pl SELECT * FROM People WHERE ( ( Name LIKE ? AND Name LIKE ? AND Name LI +KE ? AND Name LIKE ? ) ) '%Orlando%' '%Miguel%' '%Jose%' '%Fernando%'
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to build a where clause to insert into a DBIx::Class Query
by phildeman (Scribe) on Jan 29, 2018 at 14:39 UTC |