[Dbix-class] why is this returning an hash?

will trillich will.trillich at serensoft.com
Thu May 16 14:24:20 GMT 2013


If you have a lot of result rows that you're expecting, assigning the whole
set to an array might cause memory troubles.

I'd recommend the _rs approach for processing one at a time:

my $rs =3D $schema
    ->resultset('Mytable')
        ->*search_rs*( # note _rs suffix, instead of ->all
            { item_id =3D> $id },
        );
while ( my $item =3D $rs->next ) {
    # do useful things with $item and $item->item_status
}


On Wed, May 15, 2013 at 10:59 PM, Rajeev Prasad <rp.neuli at yahoo.com> wrote:

> from here  i understood, that if i collect output in array element, i will
> get an array.
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#search
>
> in below, $id is unique in the table, so it returns just one row.
>
> my @item_array =3D $schema->resultset('Mytable')->search(
>         { item_id =3D> $id },
>         { select   =3D> [qw/item_status/] }
>         );
> print "print array =3D at item_array\n";
>
>
>  ./test.pl
> node status=3DDb::Schema::Result::Mytable=3DHASH(0x17b9cf8)
> $
>
>
> I actually/finally  want to get the value of an specific column by
> supplying $id. not sure how to get that.
>
> _______________________________________________
> 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
>



-- =

 Will Trillich :: 812.454.6431

=93Grading takes away all the fun from failing. And a huge part of education
is about failure.=94  -- Shimon Schocken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130516/431=
93ba7/attachment.htm


More information about the DBIx-Class mailing list