I've been following the ManyToMany examples and I'm stuck. Seems like I'm
missing something obvious, but can't see it.
Typical storefront. Here's my relevant class info:
--------
package AL::Fresco::StoreOrder;
use base qw(AL::Fresco::DB::Object);
use AL::Fresco::StoreOrdersProducts;
__PACKAGE__->meta->setup(
...
relationships => [
products => {
#column_map => {store_order_id => 'id'},
#foreign_class => 'AL::Fresco::StoreProduct',
map_class =>
'AL::Fresco::StoreOrdersProducts',
map_from => 'product',
map_to => 'order',
type => 'many to many',
},
],
);
1;
-----------
package AL::Fresco::StoreProduct;
use strict;
use base qw(AL::Fresco::DB::Object);
use AL::Fresco::StoreOrdersProducts;
__PACKAGE__->meta->setup(
...
relationships => [
orders => {
#column_map => {store_product_id => 'id'},
#foreign_class => 'AL::Fresco::StoreOrder',
map_class =>
'AL::Fresco::StoreOrdersProducts',
map_from => 'product',
map_to => 'order',
type => 'many to many',
},
],
);
1;
------------
package AL::Fresco::StoreOrdersProducts;
use strict;
use base qw(AL::Fresco::DB::Object);
use AL::Fresco::StoreOrder;
use AL::Fresco::StoreProduct;
__PACKAGE__->meta->setup(
table => 'store_orders_products',
columns => [
store_product_id => {type => 'int', not_null => 1},
store_order_id => {type => 'int', not_null => 1},
],
foreign_keys => [
order => {
class => 'AL::Fresco::StoreOrder',
key_columns => {store_order_id => 'id'},
},
product => {
class => 'AL::Fresco::StoreProduct',
key_columns => {store_product_id => 'id'},
},
],
);
1;
and yet this doesn't work:
my $p = AL::Fresco::StoreProduct->new(
price => '79.99',
license => 1,
description => 'PO tester',
currency_id => 2,
site_id => 2,
);
my $order = AL::Fresco::StoreOrder->new(
uid => AL->random,
type => $t,
industry => $i,
hearabout => $h,
lastname => 'Tester',
firstname => 'Joe',
email => '[EMAIL PROTECTED]',
products => [$p]
);
dies with error:
Can't locate object method "products" via package "AL::Fresco::StoreOrder"
Methods for the following relationships and foreign keys were deferred and
then never actually created in the class AL::Fresco::StoreOrder.
TYPE NAME
---- ----
Relationship products
I see the 'get_set' and 'get_set_now' options for method maps in the docs, but
not sure if they are applicable or how to use them.
TIA,
pek
--
Peter Karman . http://peknet.com/ . [EMAIL PROTECTED]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object