Hi~
I am new to dbix-class also SQL, in my test script I want to select from
two tables:
$ sqlite3 test.db
SQLite version 3.3.13
Enter ".help" for instructions
sqlite> .schema
CREATE TABLE author (
uid integer primary key,
uname text not null
);
CREATE TABLE news (
newsid integer primary key,
uid integer not null references author(uid),
title text not null,
body text not null
);
I want to get the news.title, news.body, and author.uname, but I can not
find out the method now.
###schema:
package My::Schema;
use base qw/DBIx::Class::Schema::Loader/;
__PACKAGE__->loader_options( relationships => 1, debug => 1,);
#ps: if relationships option is omited, "relationships" seems to be faulse,
but document say :"The default is to attempt the loading of relationships"
#__PACKAGE__->loader_options( relationships => 1, );
1;
###test script:
$ cat test.pl
#!/usr/bin/perl
use lib ".";
use My::Schema;
my $dump = $ARGV[0] || undef;
my $schema = My::Schema->connect('dbi:SQLite:/home/hx/work/dbix/test.db');
#DBIx::Class::Schema::Loader->dump_to_dir('/tmp/z');
if ($dump) {
my @news = $schema->resultset('News')->all(
{
join => [qw / author /],
}
);
for my $row (@news) {
print $row->title,"\n", $row->uid, "\n", $row->body,"\n"; # how
can I get the author name here ?
}
}
thanks!
_______________________________________________
List: http://lists.rawmode.org/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]