[Catalyst] basic CRUD confusion
Jack Lauritsen
jack.lauritsen at gmail.com
Sat Mar 31 14:26:11 GMT 2007
Hello,
I am building a (test only) site based modifying the classes in the
catalyst tutorial, and have a hopefully simple question. I have a search
box that takes an isbn number, and then build a book with the data from
amazon web services. The problem comes when I want to update the authors
list. I don't have the author id. How do I get the id out of
MyAppDB::Author? I tried the following:
==================================
foreach my $amazonauthor ($amazonbook->made_by()) {
my $author = $c->model('MyAppDB::Author')->search({name =>
$amazonauthor});
if ($author->{id} != undef) {
$author = $c->model('MyAppDB::Author')->search({name =>
$amazonauthor});
$book->add_to_book_authors({author_id => $author->{id}});
} else {
$author = $c->model('MyAppDB::Author')->create({
name => $amazonauthor # yes, my DB has just \id name\
});
$book->add_to_book_authors({author_id => $author->{id}});
}
==================================
is the syntax wrong "$author->{id}"
or have I made the Author incorrectly?
thanks in advanced for anyone who can point me in the right direction.
Jack.
More information about the Catalyst
mailing list