[Dbix-class] fetching a column value directly

2013-11-03 Thread Rajeev Prasad
hello, I have this host table, which has all unique records. So i want to get a specific column value for a specific host. i am doing below, but i think it is not efficient. is there a better way? my $hostAdd_rs = $schema-resultset('Host')-search({host=$host},{select=[qw/addr/]}); while (my

Re: [Dbix-class] fetching a column value directly

2013-11-03 Thread Hailin Hu
1. Define column host as unique in your Result pm, then you can use $rs-find({ host = $host })-addr; 2. Use method first() $hostAdd = $rs-search({host = $host})-get_column('addr')-first; On Mon, Nov 4, 2013 at 2:29 PM, Rajeev Prasad rp.ne...@yahoo.com wrote: hello, I have this host table,

Re: [Dbix-class] fetching a column value directly

2013-11-03 Thread Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
Your code is correct. `search` may return several results, so you must either iterate over them or assign/do something with all the results, e.g. -search(…)-all returns a list of Host resultrow objects. If you are sure the hosts is unique and therefore `search` will only find one result, you