Example #1
0
 /**
  * Queries the log table to find batch id for the job's last execution.
  * 
  * Note: This function expects the log entries to be formated by the
  * OutputLog feature class. 
  * 
  * @param SporkTools\Core\Job\AbstractJob $job
  * @return boolean|string
  */
 protected function fetchLastBatchId(AbstractJob $job)
 {
     $sql = new Sql($this->db);
     $message = 'Starting job ' . str_replace('\\', '\\\\', $job->getName()) . ' [%]';
     $select = new Select($this->table);
     $select->columns(array('message' => $this->columnMap['message']))->order($this->columnMap['timestamp'] . ' desc')->limit(1)->where->like($this->columnMap['message'], $message);
     $statement = $sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     //$results = $this->db->query($select->getSqlString($this->db->getPlatform()), Adapter::QUERY_MODE_EXECUTE);
     if (count($results) == 0) {
         return false;
     }
     $row = $results->current();
     $message = $row['message'];
     return substr($message, strrpos($message, '[') + 1, 13);
 }
Example #2
0
 protected function storeData(AbstractJob $job, $type, $data)
 {
     $table = $this->getTable();
     $set = array($this->columnMap['job'] => $job->getId(), $this->columnMap['type'] => $type);
     $table->delete($set);
     $set[$this->columnMap['data']] = serialize($data);
     $table->insert($set);
 }