Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Problem with column in DBI

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


naylorgarcia at gmail

May 19, 2009, 12:40 PM

Post #1 of 6 (856 views)
Permalink
Problem with column in DBI

HI,

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?

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

Thank you ;)

Naylor Garcia


pawad at yandex

May 19, 2009, 1:15 PM

Post #2 of 6 (818 views)
Permalink
Re: Problem with column in DBI [In reply to]

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

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?

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

Thank you ;)

Naylor Garcia


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


naylorgarcia at gmail

May 19, 2009, 1:51 PM

Post #3 of 6 (818 views)
Permalink
Re: Problem with column in DBI [In reply to]

Thank you Very much,,,

Its working now!

2009/5/19 Павел Долженко <pawad [at] yandex>

> my $change_color = [.$c->model('database::dominio')->search(
> { id_domain => 21240, name => { like => 'naylor garcia' } },
> {columns => ['color']}
> )->first->color];
>
> HI,
>
> 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?
>
> my $change_color = [.$c->model('database::dominio')->search(
> { id_domain => 21240, name => { like => 'naylor garcia' } }
> )];
>
> Thank you ;)
>
> Naylor Garcia
>
> ------------------------------
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>


michael.reddick at gmail

May 19, 2009, 1:53 PM

Post #4 of 6 (812 views)
Permalink
Re: Problem with column in DBI [In reply to]

On Tue, May 19, 2009 at 2:40 PM, Naylor Garcia <naylorgarcia [at] gmail>wrote:

> HI,
>
> 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?
>
>
>
Check out the DBIx::Class manual here:

http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual.pod


naylorgarcia at gmail

May 19, 2009, 1:56 PM

Post #5 of 6 (817 views)
Permalink
Re: Problem with column in DBI [In reply to]

I found the manual, so I asked!


2009/5/19 Michael Reddick <michael.reddick [at] gmail>

>
>
> On Tue, May 19, 2009 at 2:40 PM, Naylor Garcia <naylorgarcia [at] gmail>wrote:
>
>> HI,
>>
>> 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?
>>
>>
>>
> Check out the DBIx::Class manual here:
>
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual.pod
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>


bobtfish at bobtfish

May 20, 2009, 3:09 AM

Post #6 of 6 (797 views)
Permalink
Re: Problem with column in DBI [In reply to]

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 [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.