How do i pass a variable for the query in a get Manager call?

拈花ヽ惹草 提交于 2019-12-12 05:14:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!