Can somebody help me with the correct approach on updating multiple records related to a table and based on a condition.
I am trying to update the field is_deleted
for all comments in comment table, if the comment is related to a deleted post.
Below is the code I tried.
$commentsTable->query()
->join([
'table' => 'Posts',
'type' => 'inner',
'conditions'=> ['Posts.id = Comments.post_id', 'Posts.is_deleted = 1'],
])->updateAll(['Comments.is_deleted' => 1],[]);
I can use simple query to do this, but want to know how to handle this using Cakephp Query Builder.