I have been breaking my head on a "problem" that should not be that
complex. Maybe it is a shortcoming of Outlet, but I think I am missing
something.
Context: the simple Order / OrderLine situation
One Order
- can have multiple orderLines (one-to-many)
- is taken care of by one ServiceProvider, who can handle multiple
orders (many-to-one)
- is placed by a ServiceConsumer, who can place multiple orders (many-
to-one)
One OrderLine
- is related to one specific Order, but multiple OrderLines can exist
in a single Order (many-to-one)
- is related to one CatalogItem (or product), but a CatalogItem can
occur in multiple OrderLines (many-to-one)
Approach (pseudo) - addProduct():
- $order = new Order();
- $orderLine[1..N] = new OrderLine();
- $order->addOrderLine($orderline1);
- $order->addOrderLine($orderline2);
- $order->addOrderLine($orderlineN);
$dao = new Dao_Outlet_Order()
$dao->save($order);
However, this seems to result in a lifelock:
- Order is saved, OrderLines are detected
- OrderLines need to be saved, primary key of the Order is set
(orderId) based on the acquired auto incremented ID
- OrderLine is saved, but this detects that the Order needs to be
saved (in the OutletMapper::isNew() method)
I have tried Outlet-RC1 and the latest trunk versions, but both finish
with a lot of Orders added to the database, no Orderlines added and an
out of memory exception.
What am I missing here? I searched to group and documentation, this
post seems to relate but it is quite old:
http://groups.google.com/group/outlet-orm/browse_thread/thread/7c32ebeb0af22779/e18f28fe57ed7c06?lnk=gst&q=orderline#e18f28fe57ed7c06
For the sake of simplicity, I will present only the relevant part of
my configuration:
Note that the table of the Orders is called "orders", while I tend to
use the object name: "order", but this interferes with the SQL
standard, might this be the problem? As in some queries still {Order}
will be used?
array(2) {
["connection"] => array(4) {
["dialect"] => string(5) "mysql"
...
}
["classes"] => array(2) {
["Order"] => array(3) {
["table"] => string(6) "orders"
["props"] => array(3) {
["orderId"] => array(3) {
[0] => string(7) "orderId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(true)
["autoIncrement"] => bool(true)
}
}
}
["associations"] => array(1) {
[0] => array(3) {
[0] => string(11) "one-to-many"
[1] => string(10) "Order_Line"
[2] => array(3) {
["key"] => string(7) "orderId"
["name"] => string(9) "OrderLine"
["plural"] => NULL
}
}
}
}
["Order_Line"] => array(3) {
["table"] => string(9) "orderline"
["props"] => array(4) {
["orderLineId"] => array(3) {
[0] => string(11) "orderLineId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(true)
["autoIncrement"] => bool(true)
}
}
["orderId"] => array(3) {
[0] => string(7) "orderId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(false)
["autoIncrement"] => bool(false)
}
}
}
["associations"] => array(1) {
[0] => array(3) {
[0] => string(11) "many-to-one"
[1] => string(5) "Order"
[2] => array(3) {
["key"] => string(7) "orderId"
["name"] => NULL
["optional"] => NULL
}
}
}
}
}
}