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\nodeviewcountCode
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();
}