I'm currently encountering some strange behaviour when I'm using updateAll method.
I'll explain my database schema
Table A
- id as primary key
- b_fk as foreign key to table B
- bar as another field
Table B
- id as primary key
- foo as a column
Table C
- id as primary key
- a_fk as foreign key to table A
Table D
- id as primary key
- a_fk as foreign key to table A
As you can see, A has many C's (a C belongs to A), A has many D's (a D belongs to A), an A has one (or none) B
I'm running 2 queries (in a transaction, of course)
$ModelTableA->updateAll(
array('A.b_fk' => null),
array(
'OR' => array(
'A.b_fk' => $values,
'A.bar' => $value
)
)
);
$ModelTableB->deleteAll(
array('B.id' => $ids)
);
The problem is that updateAll triggers more than one query. First it fetches some rows (from A table based on conditions from updateAll), then all dependecies (from C and D tables) and then runs the update on the A table based on primary keys not on the conditions I specified. The update part is ok, it updates what I want to be updated
How can I disable this behavior?
I just want an atomic query, I don't want all the mambo-jambo, the C and D tables will be populated heavily, a lookup on them for a simple update action is not my intention.
Thank you for your help,
Adrian
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:
Post a Comment