[Catalyst] DBIx relationships

Mesdaq, Ali amesdaq at websense.com
Fri Dec 7 19:44:45 GMT 2007


 
 I am still very much a beginner myself but from one beginner to another
it looks like your schema is not a many to many type. You would need a
table to bring the family and members together like
family_members(male_id, female_id, family_id)
Then you could have a search on the family table and list out all the
members like
my $rs = $c->model(''AppModelDB::Family')->search({family_id => #id});
while ($rs->next)
{
	print $_->male->first_name, $_->family->family;
	print $_->female->first_name, $_->family->family;
}

Please correct me if I am wrong anyone on the list because I am still
trying to get the hang of it myself.

Thanks,
------------------------------------------
Ali Mesdaq (CISSP, GIAC-GREM)
Security Researcher II
Websense Security Labs
http://www.WebsenseSecurityLabs.com
------------------------------------------

________________________________

From: Angel Kolev [mailto:ankolev at gmail.com] 
Sent: Friday, December 07, 2007 11:21 AM
To: catalyst at lists.scsys.co.uk
Subject: [Catalyst] DBIx relationships


Guys,
i cant understand relationships yet (has_many and many_to_many too). 
I have 3 tables in my datebase:
"males" (id,first_name,family_name) etc
"females" (id,first_name,family_name) etc
and "family" (id,family,city,address) etc

All "id"s are equal. I have classes for all of them
(MyApp::Males,::Females,::Family). Every male and female with same ID
belongs to same ID in the "family" table. So i want to fetch one "line"
through MyApp::Family at once. Something like: 
$c->model('AppModelDB::Family')->family
#id,city,first_name(female),first_name(male)

Thank you





Click here
<https://www.mailcontrol.com/sr/o5qG9EVieck13K4hCHgocuaezl6vIhKaF2MvW56w
q5n5v+5pGstheR4+CWTOHVIPC8xG6KV63TzWRagmh6U2E6ni+wO5wLv4999QL!oSPGUdP5sc
ULzIWoXT0xqRtC1Ms9EUn8V!sujYWnNTNVfud2qAOcypvK+JTUUd+2adAL3!tmJLfymf8esr
J8FNtBBajQMNIEaOjhRSnGos6ruelSl1jpaPNlJ6>  to report this email as spam.




More information about the Catalyst mailing list