问题
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
回答1:
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?
回答2:
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
来源:https://stackoverflow.com/questions/14678236/how-do-i-pass-a-variable-for-the-query-in-a-get-manager-call