Exemple #1
0
 /**
  * Stores a run object to the database.
  *
  * @param   Run     $run
  *
  * @throws  InvalidArgumentException
  */
 public function persist(Run $run)
 {
     if (empty($run->getRunId())) {
         throw new \InvalidArgumentException('missing run id');
     }
     $conn = $this->database->getConnection();
     $stmt = $conn->prepare('REPLACE INTO runs (run_id, ts_created, ts_accessed)' . ' VALUES (:run_id, :ts_created, :ts_accessed)');
     $now = time();
     $stmt->bindValue(':run_id', $run->getRunId());
     $stmt->bindValue(':ts_accessed', $now);
     $stmt->bindValue(':ts_created', $run->getTsCreated() ?? $now);
     $stmt->execute();
 }