Re: [Catalyst] DBIx relationships

2007-12-16 Thread Matt S Trout
On Sat, Dec 08, 2007 at 03:44:18AM +0200, Angel Kolev wrote:
> 2007/12/8, J. Shirley <[EMAIL PROTECTED]>:
> >
> >
> > First, two things:
> > #1. This is not the DBIC mailing list
> > #2. It is called "DBIx::Class" or "DBIC".  DBIx is an entire namespace
> > hosting many projects.  DBIx::Class is just one of those projects.
> >
> > Thanks,
> > -Jay
> >
> 
> Sorry but im just badly stucked at this :(

You're going to keep being stuck if you ask DBIx::Class questions on the
Catalyst list. DBIx::Class is a separate project with its own mailing list.
Ask on there and you'll find people are much more willing to help.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://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: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBIx relationships

2007-12-08 Thread Angel Kolev
Thank you very much, Peter.

Yeah i use $c->stash->{books} = [$c->model('MyAppDB::Book')->all] in my
template and it works. I just want to make too many changes in the result of
it before send them to my TT. Now ill try what you wrote here. Thank you
again.

Angel


2007/12/8, Peter Edwards <[EMAIL PROTECTED]>:
>
>  Angel,
>
>
>
> I'd recommend working through the tutorial, it explains many things
>
>
> http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manual/Tutorial.pod
>
>
>
> Looking at your code, on each iteration with $line in $rs->next you are
> setting the entire body, overwriting whatever you put in the previous time.
> So you end up only showing the last row found. Something like this would
> show all the lines
>
>
>
>   $c->response->body( $c->response->body . $line->first_name . "\n" );
>
>
>
> In practice you put DBIC objects like $rs in the stash and call DBIC
> methods on them from inside your TT templates.
>
>
>
> In the tutorial in the controller:
> http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod#CREATE_A_CATALYST_CONTROLLER
>
>
>
>   $c->stash->{books} = [$c->model('MyAppDB::Book')->all];
>
>
>
> And then further down the tutorial inside the template:
> http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod#Create_a_TT_Template_Page
>
>
>
> [% FOREACH book IN books -%]
>
> 
>
> [% book.title %]
>
> [% book.rating %]
>
> ...
>
> 
>
> [% END -%]
>
>
>
>
>
> Subscribe to the DBIx::Class user and developer list at
> http://lists.scsys.co.uk/mailman/listinfo/dbix-class
>
>
>
> DBIC documentation map at
>
>
> http://search.cpan.org/~blblack/DBIx-Class-0.07006/lib/DBIx/Class/Manual/DocMap.pod
>
>
>
>
>
> Regards, Peter
>
> http://perl.dragonstaff.co.uk
>
>
>
> 
>
> From: Angel Kolev [mailto:[EMAIL PROTECTED]
>
>
>
> Sorry but im just badly stucked at this :(
>
> I want to iterate using the model
>
>
>
> my $rs = $c->model('AppModelDB::ClientMale')->search();
>
> while (my $line = $rs->next) {
>
>   $c->response->body($line->first_name);
>
> }
>
>
>
> The result is always one name. I need all fields them to put them in TT
> template.
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/[EMAIL PROTECTED]/
> Dev site: http://dev.catalyst.perl.org/
>
>
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


RE: [Catalyst] DBIx relationships

2007-12-08 Thread Peter Edwards
Angel, 

 

I'd recommend working through the tutorial, it explains many things

http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manua
l/Tutorial.pod

 

Looking at your code, on each iteration with $line in $rs->next you are
setting the entire body, overwriting whatever you put in the previous time.
So you end up only showing the last row found. Something like this would
show all the lines

 

  $c->response->body( $c->response->body . $line->first_name . "\n" );

 

In practice you put DBIC objects like $rs in the stash and call DBIC methods
on them from inside your TT templates.

 

In the tutorial in the controller:
http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manua
l/Tutorial/CatalystBasics.pod#CREATE_A_CATALYST_CONTROLLER

 

  $c->stash->{books} = [$c->model('MyAppDB::Book')->all];

 

And then further down the tutorial inside the template:
http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/lib/Catalyst/Manua
l/Tutorial/CatalystBasics.pod#Create_a_TT_Template_Page

 

[% FOREACH book IN books -%]



[% book.title %]

[% book.rating %]

...



[% END -%]

 

 

Subscribe to the DBIx::Class user and developer list at
http://lists.scsys.co.uk/mailman/listinfo/dbix-class

 

DBIC documentation map at

http://search.cpan.org/~blblack/DBIx-Class-0.07006/lib/DBIx/Class/Manual/Doc
Map.pod

 

 

Regards, Peter

http://perl.dragonstaff.co.uk  

 



From: Angel Kolev [mailto:[EMAIL PROTECTED] 

 

Sorry but im just badly stucked at this :(

I want to iterate using the model

 

my $rs = $c->model('AppModelDB::ClientMale')->search();

while (my $line = $rs->next) {

  $c->response->body($line->first_name);

}

 

The result is always one name. I need all fields them to put them in TT
template. 

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


Re: [Catalyst] DBIx relationships

2007-12-07 Thread Angel Kolev
2007/12/8, J. Shirley <[EMAIL PROTECTED]>:
>
>
> First, two things:
> #1. This is not the DBIC mailing list
> #2. It is called "DBIx::Class" or "DBIC".  DBIx is an entire namespace
> hosting many projects.  DBIx::Class is just one of those projects.
>
> Thanks,
> -Jay
>

Sorry but im just badly stucked at this :(
I want to iterate using the model

my $rs = $c->model('AppModelDB::ClientMale')->search();
while (my $line = $rs->next) {
  $c->response->body($line->first_name);
}

The result is always one name. I need all fields them to put them in TT
template.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBIx relationships

2007-12-07 Thread Jonathan Rockway

On Fri, 2007-12-07 at 17:07 -0800, J. Shirley wrote:

> #1. This is not the DBIC mailing list
> #2. It is called "DBIx::Class" or "DBIC".  DBIx is an entire namespace
> hosting many projects.  DBIx::Class is just one of those projects. 


Hey, purl can post to mailing lists now :)


signature.asc
Description: This is a digitally signed message part
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBIx relationships

2007-12-07 Thread J. Shirley
On Dec 7, 2007 11:20 AM, Angel Kolev <[EMAIL PROTECTED]> wrote:

> 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
>

First, two things:
#1. This is not the DBIC mailing list
#2. It is called "DBIx::Class" or "DBIC".  DBIx is an entire namespace
hosting many projects.  DBIx::Class is just one of those projects.

Thanks,
-Jay
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


RE: [Catalyst] DBIx relationships

2007-12-07 Thread Mesdaq, Ali
 
 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:[EMAIL PROTECTED] 
Sent: Friday, December 07, 2007 11:21 AM
To: catalyst@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.


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


[Catalyst] DBIx relationships

2007-12-07 Thread Angel Kolev
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
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/