I am updating record by following query but not working?

I am updating record by following query but not working ? code is worked because their is no any error and showing the flash message

$this->Rates->query()
                            ->update()
                            ->set(["rates"=>json_encode($rateInfo)])
                            ->where(['metal' => $allResult->metal])
                            ->execute();

then what’s problem with my code ? modified field not update when fire the query.

Can’t confirm because this raw update query works fine for me.
Are you sure you look at/use the correct database?

Also: The modified field can’t be updated like that because you are not using the ORM to update an entity.

If you want the modified field to be updated for all of those entries you will first have to query all your entities and manually update them like so:

$query = $this->Rates->find()->where(['metal' => $allResult->metal]);
$result = $query->all()->toArray();
foreach($result as $entity) {
    $entity = $this->Rates->patchEntity($entity, ['rates' => json_encode($rateInfo)]);
    $isSaved = $this->Rates->save($entity);
}