Help with passing variables in query using 'ilike'

19 views
Skip to first unread message

A Nopouc

unread,
Mar 12, 2015, 1:47:57 PM3/12/15
to rose-db...@googlegroups.com
I am very new at using RoseDB. I have a simple query in which I need to pass multiple values to the query, but I need to place those values in a variable. I am receiving multiple values from user input that I need to break up and send them to the query.

So how can I take the example
 title    => { like => [ '%million%',
                                '%resident%' ] },

and do something like

    my @keywordJoin;
    my $newKeyword;
    my $searchItem = $fdat->{sSearch};
 
    my @keywords = split(' ', $searchItem );
      foreach (@keywords) {
         $newKeyword = " '%$_%' ";
         push(@keywordJoin, $newKeyword); 
     }
  
 my $string = join(" , ",@keywordJoin);

 title    => { like => [ \$string ] } (this does not work!!!!)

Any advice is greatly appreciated.

John Siracusa

unread,
Mar 12, 2015, 3:12:23 PM3/12/15
to rose-db...@googlegroups.com
Try:

  title => { like => \@keywordJoin },

-John

A Nopouc

unread,
Mar 12, 2015, 5:11:44 PM3/12/15
to rose-db...@googlegroups.com
Thanks, but that did not work.  The query does not "read" the values passed in, only the length of the array. When the array had two values, the query looked like
    Where (t3.keyword ILIKE ? OR t3.keyword ILIKE ?)
Any more suggestions?

John Siracusa

unread,
Mar 12, 2015, 11:14:22 PM3/12/15
to rose-db-object
What is the SQL you want to be generated for this query?

-John

--
--
CPAN: http://search.cpan.org/dist/Rose-DB-Object
SVN: http://rose.googlecode.com/svn/trunk/modules/Rose-DB-Object
SVN Instructions: http://code.google.com/p/rose/source/checkout
Unsubscribe: rose-db-objec...@googlegroups.com
List Options: http://groups.google.com/group/rose-db-object

---
You received this message because you are subscribed to the Google Groups "Rose::DB::Object" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rose-db-objec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages