FAQ
Dear Mailing List,
i'm developing an utility to administrate some things in an intranet
enviroinment.
I've got two tables one with 3 fields :
id,
seminar_group_id,
desc

and the other one that contains 3 fields also
id,
seminar_group_id
role_id

the second table contains the seminar group id that a role is able to see.
what i want to get is a complete list of the groups , and field that
return true or false if a user can see the group.
i got this by executing this query
select
a.id,
group_name,
role_id
from
seminari_gruppi a
left join
seminar_2_roles b
on
( a.id = b.seminar_group_id AND role_id = $role_id)

looking into google i've discovered that this can be done by using the
from, and this is what i've done

my $allGroups_rs = $c->model('DbsMysql::Seminars::Gruppi')->search(undef,
{ from => \"
(SELECT a.id , group_name, group_desc, testo , img ,
role_id FROM seminari_gruppi a
LEFT JOIN seminar_2_roles b
ON a.id = b.seminar_group_id
AND b.role_id = $id_role
) me"
});

but... how can i access role_id ? as i can do a thing like this
push @{$json->{groups}} , {
group_id => $r->id,
group_desc => $r->group_desc,
group_name => $r->group_name,
cansee => defined $r->{role_id} ? JSON::XS::true :
JSON::XS::false
};
Thanks guys!

Search Discussions

  • Eden Cardim at Sep 7, 2010 at 6:00 pm
    "Tiziano" == Tiziano Faion writes:

    Tiziano> my $allGroups_rs =
    Tiziano> $c->model('DbsMysql::Seminars::Gruppi')->search(undef, {
    Tiziano> from => \" (SELECT a.id , group_name, group_desc, testo ,
    Tiziano> img , role_id FROM seminari_gruppi a LEFT JOIN
    Tiziano> seminar_2_roles b ON a.id = b.seminar_group_id AND
    Tiziano> b.role_id = $id_role ) me" });

    Tiziano> but... how can i access role_id ? as i can do a thing like
    Tiziano> this push @{$json->{groups}} , { group_id => $r->id,
    Tiziano> group_desc => $r->group_desc, group_name => $r->group_name,
    Tiziano> cansee => defined $r->{role_id} ? JSON::XS::true :
    Tiziano> JSON::XS::false }; Thanks guys!

    try:

    $rs->search({},{ '+select' => [qw(role_id)] })
    $row->get_column('role_id');

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbix-class @
categoriesperl, catalyst
postedSep 1, '10 at 5:09p
activeSep 7, '10 at 6:00p
posts2
users2
websitedbix-class.org
irc#dbix-class

2 users in discussion

Eden Cardim: 1 post Tiziano Faion: 1 post

People

Translate

site design / logo © 2022 Grokbase