protected function insert($userId, HistoryEntry $entry, UserSettings $userSettings) { /** @var \PDOStatement $stmt */ try { $sql = 'INSERT IGNORE INTO `*PREFIX*sipgate_history` SET userId=:userId, status=:status, tos=:tos, time=:time, localUri=:localUri, remoteUri=:remoteUri, remotePhoneNumber=:remotePhoneNumber, localPhoneNumber=:localPhoneNumber'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':userId', $userId, \PDO::PARAM_STR); $stmt->bindValue(':status', $entry->getStatus(), \PDO::PARAM_STR); $stmt->bindValue(':tos', $entry->getTypeOfService(), \PDO::PARAM_STR); $stmt->bindValue(':time', $entry->getTime()->format('Y-m-d H:i:s'), \PDO::PARAM_STR); $stmt->bindValue(':localUri', $entry->getLocalUri(), \PDO::PARAM_STR); $stmt->bindValue(':remoteUri', $entry->getRemoteUri(), \PDO::PARAM_STR); $stmt->bindValue(':remotePhoneNumber', $entry->getRemotePhoneNumber($userSettings->getDefaultCountryCode()), \PDO::PARAM_STR); $stmt->bindValue(':localPhoneNumber', $entry->getLocalPhoneNumber($userSettings->getDefaultCountryCode()), \PDO::PARAM_STR); $stmt->execute(); return $stmt->rowCount(); } catch (DbException $e) { $this->logger->error('Error inserting into database: %s', $e->getMessage()); } }
public function historyGetByDate(\DateTime $start = null, \DateTime $end = null, $localUriList = null, $statusList = null) { $result = $this->call('samurai.HistoryGetByDate', ['PeriodStart' => is_null($start) ? null : $start->format('Y-m-d\\TH:i:s'), 'PeriodEnd' => is_null($end) ? null : $end->format('Y-m-d\\TH:i:s'), 'StatusList' => $statusList, 'LocalUriList' => $localUriList]); return array_map(function ($entry) { return HistoryEntry::fromResponse($entry); }, $result['History']); }