You are here

public function NodeViewCountRecordsManager::insertRecord in Node view count 8

Throws

\Exception

Overrides NodeViewCountRecordsManagerInterface::insertRecord

File

src/NodeViewCountRecordsManager.php, line 51

Class

NodeViewCountRecordsManager
Provides a class for interacting with nodeviewcount records.

Namespace

Drupal\nodeviewcount

Code

public function insertRecord($uid, $nid, $uip) {
  $timeZone = date_default_timezone_get();
  $dateTime = new DrupalDateTime('NOW', $timeZone);
  $stringDate = $dateTime
    ->format(DEFAULT_TIME_FORMAT);
  $fields = [
    'nid' => $nid,
    'uid' => $uid,
    'datetime' => strtotime($stringDate),
    'uip' => $uip,
  ];
  $this->connection
    ->insert('nodeviewcount')
    ->fields($fields)
    ->execute();
}