Tuesday, March 2, 2010

Re: useTable problem?

Had similar problem with HABTM relation too - by unknown reason Cake
creates AppModel instance for M:M link table instead of existing
model. In my case it was solved by switching order of models load -
make first "problem" models load and only then load models with them
in associations. I done it by $uses = array('OrderPayment', ...,
'Order') - listed all linked models before the only one really needed.
Don't know will this help you too.

On Mar 3, 1:12 am, DragonFlyEye <dragonflyey...@gmail.com> wrote:
> 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: