Exemplo n.º 1
0
 public function insert(Job $job)
 {
     $condition = array('class' => $job->class->getValue(), 'hash' => $job->hash->getValue(), 'status' => Job::NewStatus);
     $found = DBSimple::get(self::TableName, $condition);
     if (!empty($found)) {
         $job->setData($found);
     } else {
         // Real insert code
         throw new Exception('Code not ready yet');
     }
 }
 public function insert(Job $job)
 {
     foreach ($this->data as $key => $row) {
         $isSameClass = $job->class->getValue() == $row->class->getValue();
         $isSameHash = $job->hash->getValue() == $row->hash->getValue();
         $isSameStatus = $job->status->getValue() == $row->status->getValue();
         if ($isSameClass && $isSameHash && $isSameStatus) {
             $this->data[$key] = $row;
             $job->setData($this->data[$key]->getData());
             return;
         }
     }
     $job->id = $this->incrementValue;
     $this->incrementValue++;
     $this->data[] = $job;
 }