id() === 0) { $database = \Drupal::database(); if ($database->databaseType() === 'mysql') { $sql_mode = $database->query("SELECT @@sql_mode;")->fetchField(); $database->query("SET sql_mode = '$sql_mode,NO_AUTO_VALUE_ON_ZERO'"); } } parent::doSaveFieldItems($entity, $names); // Reset the SQL mode if we've changed it. if (isset($sql_mode, $database)) { $database->query("SET sql_mode = '$sql_mode'"); } } /** * {@inheritdoc} */ public function updateLastLoginTimestamp(UserInterface $account) { $this->database->update($this->getDataTable()) ->fields(['login' => $account->getLastLoginTime()]) ->condition('uid', $account->id()) ->execute(); // Ensure that the entity cache is cleared. $this->resetCache([$account->id()]); } /** * {@inheritdoc} */ public function updateLastAccessTimestamp(AccountInterface $account, $timestamp) { $this->database->update($this->getDataTable()) ->fields([ 'access' => $timestamp, ]) ->condition('uid', $account->id()) ->execute(); // Ensure that the entity cache is cleared. $this->resetCache([$account->id()]); } /** * {@inheritdoc} */ public function deleteRoleReferences(array $rids) { // Remove the role from all users. $this->database->delete('user__roles') ->condition('roles_target_id', $rids, 'IN') ->execute(); $this->resetCache(); } }