[Dbix-class] Return column values not objects?
Jason Galea
lists at eightdegrees.com.au
Tue Oct 5 03:16:26 GMT 2010
On Tue, Oct 5, 2010 at 12:58 PM, <seasprocket at gmail.com> wrote:
> The docs appear to say that DBIx can return column values (rather than
> objects), but I can't get it to work. Have tried "select" attribute and also
> "columns" attribute. In both cases, it inflates to objects. I have a simple
> (left) join of two tables and want to retrieve all the id's of the "foo"
> table.
> $rs = $self->schema->resultset('My:Bar');
> my @foo_ids = $rs->search(
> {
> bar => $bar->id,
> },
> {
> join => 'foo',
> select => [qw/foo.id/],
> }
> );
I think you want the get_column method..
my @foo_ids = $rs->search(
{
bar => $bar->id,
},
{
join => 'foo',
select => [qw/foo.id/],
}
)->get_column('foo.id');
cheers,
J
> Sorry for this newbie question, but just can't get it to work.
> Thanks!
>
>
> --
> Bikewise: http://www.bikewise.org
>
>
> _______________________________________________
> 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
>
--
Jason Galea
Web Developer
Ph 07 40556926
Mob 04 12345 534
www.eightdegrees.com.au
More information about the DBIx-Class
mailing list