Tuesday, March 2, 2010

useTable problem?

Ok, strange behavior which is probably just a misunderstanding of a
n00b, but here goes:

I have models for 'Order,' 'OrderPayment', 'OrderDetail',
'OrderShipment', 'OrderCredit', 'OrderCoupon'. All of these, because
I'm trying to transition from an old system into a new system, have
tables with different naming conventions, specifically 'LatteOrder,'
'LatteOrderPayment', 'LatteOrderDetail', 'LatteOrderShipment',
'LatteOrderCredit', 'LatteOrderCoupon'. In the models, I have them
using the proper table names:

class OrderPayment extends AppModel {
var $name = 'OrderPayment';
var $useTable = 'latteorderpayment';
var $primaryKey = 'PaymentID';
}

And in any one of those cases, I can setup a controller and view and
complete the "circuit" if you will. They all seem to be working
independently of one another. That includes setting up hasMany
relationships:

class Order extends AppModel {
var $name = 'Order';
var $useTable = 'latteorder';
var $primaryKey = 'LatteOrderID';
var $hasMany = array(
'OrderPayment',
'OrderDetail',
'OrderShipment',
'OrderCredit',
'OrderCoupon'
);
}
However, I have a controller which doesn't need it's own model, but
rather uses the Orders table. When I run this controller, I get an
error message:

class momExtractController extends AppController {
var $uses = array('Order');
}

Error: "Error: Database table order_payments for model OrderPayment
was not found."

If I comment out the OrderPayment table in the $hasMany variable, the
next one in line comes up as the error message. What's going on?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: