You are here

public function RoleExpireApiService::writeRecord in Role Expire 2.x

Same name and namespace in other branches
  1. 8 src/RoleExpireApiService.php \Drupal\role_expire\RoleExpireApiService::writeRecord()

Insert or update a record in the database.

Parameters

int $uid: User ID.

string $rid: Role ID.

int $expiry_timestamp: The expiration timestamp.

1 call to RoleExpireApiService::writeRecord()
RoleExpireApiService::processDefaultRoleDurationForUser in src/RoleExpireApiService.php
Sets the default role duration for the current user/role combination.

File

src/RoleExpireApiService.php, line 162

Class

RoleExpireApiService
Class RoleExpireApiService.

Namespace

Drupal\role_expire

Code

public function writeRecord($uid, $rid, $expiry_timestamp) {

  // Delete previous expiry for user and role if it exists.
  $this
    ->deleteRecord($uid, $rid);

  // Insert new expiry for user and role.
  $query = $this->database
    ->insert('role_expire');
  $query
    ->fields([
    'uid',
    'rid',
    'expiry_timestamp',
  ]);
  $query
    ->values([
    'uid' => $uid,
    'rid' => $rid,
    'expiry_timestamp' => $expiry_timestamp,
  ]);
  $query
    ->execute();
}