Emmanuel Quevillon wrote:
> Peter Rabbitson wrote:
>> Emmanuel Quevillon wrote:
>>> Hi,
>>>
>>> Sorry if my question looks stupid, but I'd like to retrieve the
>>> value of a count returned by an SQL query.
>>>
>>> I tried different things but it always return 1
>>>
>>> Here is the way I'd like it to work:
>>>
>>> ...
>>> acc => $g->name(),
>>> num => $c->model('Table')->search({'id' => $g->id},<CODE>
>>>
>>> where I tried to replace <CODE> with :
>> Ever tried search()->count ? :)
> 
> Hi Peter,
> 
> Yep, I forgot to mention it, but I also tried this solution
> with the same results -> cnt = 1.
> I also tried something else, when I change the column name that
> returns a count of 0, I also get a value of 1 as value in my hash
> table $hash->{num}
> Weird!!

You don't show the exact code, but I suspect this is a perl issue. The
code is returning a list, but you're expecting a scalar therefore only
ever get '1' i.e. a list of one.

Either, fix the code to return a scalar or to accept a list. e.g. try an
array rather than a hash.



_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to