On Tue, Oct 14, 2008 at 07:59:44PM +0100, Howe, Tom (IT) wrote:
> Hi, first post here
>
> I have a question regarding getting column names from a DBIx ::Class
> $resultset or $row.
>
> I have a DBIx::Class resultset which I'll call $rset
>
> I need to get the column names of the resultset in the correct order.
>
> I was advised by a coleague to use $rset->result_source->columns;
>
> This have me the column names of the table that was the original source of
> the resultset which initially worked ok.
>
> However, now that I am doing some selects on the table the resultset only
> contains a subset of the table columns
>
> I tried doing
>
> my $row = $rset->first;
> %row = $row->get_columns;
my @cols = grep { exists $row{$_} } $rset->result_source->columns;
or, really, if you're supplying a subset of columns, just hang onto the
array you supplied for that.
> my @cols = keys %row;
>
> But now I dont have them in the correct order.
>
> Is there anyway to get an (ordered) list of the column names from the
> $resultset or the $row
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
_______________________________________________
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/[email protected]