Too many count statements

2014-05-16 Thread heohni
Hi,

I am just reading in a json string, use json_decode() to get an array and 
then I walk through this array and do an update statement.
Really simple stuff, but in debug mode I can see for each array element the 
following statements:

1SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
`data`.`id` = 17


2SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
`data`.`id` = 17


3   SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
`data`.`id` = 17


4UPDATE `tablex`.`data` SET `player_id` = 43, `timeout` = '0', `answer` = 
'', `value` = '', `points` = '', `modified` = '2014-05-16 10:56:36' WHERE 
`tablex`.`data`.`id` = 17
Why do I get so many count statements?
How can I avoid / improve this?

Thanks!
Heidi

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Too many count statements

2014-05-16 Thread euromark
You should probably also post all your CakePHP code around the queries you 
run
We are not mind readers after all


Am Freitag, 16. Mai 2014 11:06:57 UTC+2 schrieb heohni:

 Hi,

 I am just reading in a json string, use json_decode() to get an array and 
 then I walk through this array and do an update statement.
 Really simple stuff, but in debug mode I can see for each array element 
 the following statements:

 1SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 2SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 3   SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 4UPDATE `tablex`.`data` SET `player_id` = 43, `timeout` = '0', `answer` = 
 '', `value` = '', `points` = '', `modified` = '2014-05-16 10:56:36' WHERE 
 `tablex`.`data`.`id` = 17
 Why do I get so many count statements?
 How can I avoid / improve this?

 Thanks!
 Heidi


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Too many count statements

2014-05-16 Thread José Lorenzo
For a few sad reasons, cakephp needs to do that. You can change this 
behavior by overriding AppModel::exists() and caching the result from the 
parten for the same provided id. That is my recommended solution.

On Friday, May 16, 2014 11:06:57 AM UTC+2, heohni wrote:

 Hi,

 I am just reading in a json string, use json_decode() to get an array and 
 then I walk through this array and do an update statement.
 Really simple stuff, but in debug mode I can see for each array element 
 the following statements:

 1SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 2SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 3   SELECT COUNT(*) AS `count` FROM `tablex`.`data` AS `fieldy` WHERE 
 `data`.`id` = 17


 4UPDATE `tablex`.`data` SET `player_id` = 43, `timeout` = '0', `answer` = 
 '', `value` = '', `points` = '', `modified` = '2014-05-16 10:56:36' WHERE 
 `tablex`.`data`.`id` = 17
 Why do I get so many count statements?
 How can I avoid / improve this?

 Thanks!
 Heidi


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.