I might found a part of the solution - unBindModel
$ModelTableA->unBindModel(array(
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 'hasMany' => array('C', 'D')
));
This way the ActiveRecord manages to run only 2 queries, one which takes the primary keys and one doing the update itself.
Close to the truth but not enough for me.
Is there any other solution? How can I disable that extra query for retrieving the PKs?
Thank you,
Adrian
On Thu, Dec 2, 2010 at 12:09 PM, Adrian Arnautu <arnautu.adrian@gmail.com> wrote:
Hi to all,I'm currently encountering some strange behaviour when I'm using updateAll method.I'll explain my database schemaTable A- id as primary key- b_fk as foreign key to table B- bar as another fieldTable B- id as primary key- foo as a columnTable C- id as primary key- a_fk as foreign key to table ATable D- id as primary key- a_fk as foreign key to table AAs 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) BI'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 updatedHow 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
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