简体   繁体   中英

How do I make doctrine do not try to update a table?

I'm working on a project where we use views to create a interface/layer between another system which is a datasource but have no matching model. This way, in my system, these views are in fact models. Everything is working perfectly fine until now, except for this part:

-------------------------------
|Table    |Table        |View |
-------------------------------
|Order  > |OrderItem  > |Item |
-------------------------------

Relation: Order (has many)> OrderItem (has many)> Item.

I recently faced a problem where it tries to save the entire set of relations of a table (the order). The system is supposed to save the order and its items (order-items). But somehow the save ends up hiting an update on the item model which is a view and returns this error, obviously:

Code:

$order->save();

Error:

Data manipulation operation not legal on this view : UPDATE ITEM (...)

Is there a way to track this, forcing it to not occur, or set it as a read only model?

This error occurs in mysql when the view is composed of elements from different tables.

If you edit columns from the same table it's ok but if the same query tries to edit columns for different tables you have an ERROR.

Are you still using Doctrine 1.2? I think using views with Doctrine was tricky Link

ALso the error can come from the way you declared the relationship on the entities:

Having: Order Many-to-Many OrderItem Many-to-One Item.

You should make sure take the relationship OrderItem > Item is unidirectional and that OrderItem is the Owning side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM