From c895f0f7d9af520f442ef68747f52ac25703d783 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 14 Oct 2024 11:16:23 +0530 Subject: [PATCH] Update counter-cache.rst (#7927) Update counter-cache.rst Refs cakephp/cakephp#17966 --- en/orm/behaviors/counter-cache.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/en/orm/behaviors/counter-cache.rst b/en/orm/behaviors/counter-cache.rst index 46b0d0a63c..ae87db1142 100644 --- a/en/orm/behaviors/counter-cache.rst +++ b/en/orm/behaviors/counter-cache.rst @@ -131,6 +131,14 @@ then updates the counter of the *previously* associated item. behavior to the ``CommentsTable`` in order to generate ``comment_count`` for Articles table. +.. versionchanged:: 5.1.2 + + As of CakePHP 5.1.2, the counter cache values are updated using a single + query using sub-queries, instead of separate queries, to fetch the count and + update a record. If required you can disable the use of sub-queries by + setting `useSubQuery` key to `false` in the config + `['Articles' => ['comment_count' => ['useSubQuery' => false]]` + Belongs to many Usage =====================