doctrine2 - MySQL: ignore constraint within SQL transaction -


For a collection, I want to update the order of items. I have an obstacle in MySQL (Order + Archive_ID) unique, therefore, you can not have two items in sequence 1 in the same collection.

However, now I want to update the sequence of items "atomically". For my ORM, I updated all the entities with the new order and flushed to write them in the database. The ORM converts them into many questions and it violates an obstacle directly from MySQL.

Example:

I have the items A, B, C So A = 1, B = 2 and C = 3 then I update with C, B, A. So C = 1, B = 2, A = 1 are two questions, and the first update runs in direct obligation violation. In proxy:

  UPDATE item SET order = 1 WHERE id = C  

My thoughts

Is it possible to start a transaction, remove the obstacle, then apply all the changes and then enable the barrier? If failing to enable, rollback will ensure that everything will be set back.

Optional

One option is to completely eliminate the barrier, but I am very satisfied with the solution :)

< P>

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -