Naylor Garcia wrote:
I need to make a select in database of the a specific column, but the result is a array. How I do to get a specific column?

I think that you meant to post to the DBIC list.

my $change_color = [$c->model('database::dominio')->search(
        { id_domain => 21240, name => { like => 'naylor garcia' } }
)];

# N.B. UNTESTED
my $column_name = 'name';
my $rs = $c->model('database::dominio')->search(
    { id_domain => 21240, name => { like => 'naylor garcia' } },
    { columns => [ $column_name ] }, # only get one column from the DB
);
# Inflate rows to hashrefs
$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
my $change_color = [ map { $_->{$column_name } $rs->all ];


This should all be buried in a method on your ResultSet objects really - if you're putting logic like this in your Catalyst controllers than you're doing it wrong.

Cheers
t0m


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to