Thank You Rob for help.
Now it is working (but a little changed clause statement because of
Postgresql)
I run into another basic problem, that i can't solve.
I have two table:
1. Users : holds user informations, (and 'id' as primary key)
2. Photos : holds user pictures definitions, joined to Users table with
column: user_id (one user may have many photos)
I created a has_many relationship in Users resultset, and this way
i can get the count of photos for every user via : $self->photos->count;
Cut from Users resultset file with relevant sections:
package Tarsv1::Schema::Result::Users;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn",
"Core");
__PACKAGE__->table("users");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
default_value => "nextval('users_id_seq'::regclass)",
is_nullable => 0,
size => 4,
},
.
.
.
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(photos => 'Tarsv1::Schema::Result::Photos', user_id');
The other: Photos table resultset file with relvant sections:
package Tarsv1::Schema::Result::Photos;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn",
"Core");
__PACKAGE__->table("photos");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
default_value => "nextval('photos_id_seq'::regclass)",
is_nullable => 0,
size => 4,
},
"user_id",
{ data_type => "integer", default_value => 0, is_nullable => 0, size => 4 },
How can i create a clause/resultset to get only that users, which has
a photo?
In normal sql it is very sipmle:
SELECT * FROM users u,photos p WHERE u.id = p.user_id;
Sorry for long and very beginner question.
Thank You in advance!
Csabi
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]