How do i pass a variable for the query in a get Ma

2019-09-08 17:50发布

I am trying to make a simple Rose DB call: $id = xyz; $name = "company";

DataB::testTable::Manager->get_testTable( query =>[ id => $id, name => $name ] );

in it possible to not have the whole query written every time, and declare it like a string variable such that i can just call

DataB::testTable::Manager->get_testTable( query =>[ $query ] );

where $query = qq { id => $id , name => $name };

Please Help

2条回答
做个烂人
2楼-- · 2019-09-08 18:32

Well actually i figured out how to do that . Its not that complicated. Only thing is RoseDB objects expect an array reference for a query. So something like this works :

my @query = ( id => $id, name => $name );

testDB::testTable::Manager->get_testTable( query => \@query );

Just thought would answer it myself, incase someonelse is looking for a solution to this

查看更多
混吃等死
3楼-- · 2019-09-08 18:39

By what I understood from your question, I am giving this answer. Try this one.

my $myquery = {query =>{ id=>$id, name=>$name }} ;

TGI::testTable::Manager->get_testTable($myquery);

Hope, this gives some idea to you.

Edit for "Hash with Array reference":

my $myquery = [ id=>$id, name=>$name ] ;

TGI::testTable::Manager->get_testTable(query => $myquery);

check out this : How to pass a a string variable as "query" for get Manager call?

查看更多
登录 后发表回答