Why is my update query OK for the database but the page shows the wrong value?
I replaced  

foreach ($results as $key=&gt;$result) {
  $numberofrowsaffected = $database-&gt;update('person')
    -&gt;fields(['iscontact' =&gt; 0,])
    -&gt;condition('id', $result-&gt;id)
    -&gt;execute();
}


by  

  $storage = \Drupal::entityTypeManager()-&gt;getStorage('person');
  foreach ($results as $key=&gt;$result) {
    $person = $storage-&gt;load($result-&gt;id);
    $person-&gt;iscontact = 0;
    $person-&gt;save();


And it works!