Monday, May 20, 2013

Duplicate SELECT COUNT queries on row update

I have a very simple model with no relationships, and a controller function that contains the following lines:

$data = array('user_id' => $this->Auth->user('id'));
$this->Card->id = 3;
$this->Card->save($data);


When executed, the following SQL queries are generated:

SELECT COUNT(*) AS `count` FROM `db`.`cards` AS `Card` WHERE `Card`.`id` = 3
SELECT COUNT(*) AS `count` FROM `db`.`cards` AS `Card` WHERE `Card`.`id` = 3
SELECT COUNT(*) AS `count` FROM `db`.`cards` AS `Card` WHERE `Card`.`id` = 3
UPDATE `db`.`cards` SET `user_id` = 1, `modified` = '2013-05-20 15:16:47' WHERE `db`.`cards`.`id` = 3

What is the cause for the duplicate SELECT queries? I have other functions in this controller that don't behave like this. 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: