Esempio n. 1
0
 /**
  * Update file row
  *
  * @param string $pathname
  * @param SeekR_Row $row
  * @param array $newValues
  */
 protected final function _updateFileRow($pathname, SeekR_Row $row, array $newValues)
 {
     // Data
     $oldValues = $row->toArray();
     if ($oldValues['status'] == self::STATUS_REMOVED) {
         $operation = self::OPERATION_NEW;
         $oldValues = array();
     } else {
         $operation = self::OPERATION_MODIFIED;
     }
     $difference = array_diff_assoc($newValues, $oldValues);
     $scanID = $this->_scanRow->scanID;
     // Changed
     if ($difference || $operation == self::OPERATION_NEW) {
         // Has history row for this scan
         if ($historyRow = $this->_fileHistoryTable->fetchRow(array('fileID' => $row->fileID, 'scanID' => $scanID))) {
             $historyRow->setFromArray($difference)->save();
         } else {
             if ($operation != self::OPERATION_NEW) {
                 fwrite(STDOUT, "\t{$pathname} has been changed.\n");
             }
             $this->_fileHistoryTable->createRow(array('fileID' => $row->fileID, 'scanID' => $scanID, 'operation' => $operation, 'dateOnly' => count($difference) == 1 && isset($difference['modifyDate']) ? 'yes' : 'no') + $difference)->save();
         }
         // Row update
         $row->setFromArray(array('modifyScanID' => $scanID, 'status' => self::STATUS_ACTIVE) + $difference);
     }
 }
Esempio n. 2
0
 /**
  * Update row
  *
  * @param SeekR_Row $row
  */
 public final function updateRow(SeekR_Row $row)
 {
     // Insert
     $this->_db->query("UPDATE {$this->_db->quoteIdentifier($this->_name)}\nSET " . $this->_setValues(array_diff_assoc($row->toArray(), $row->getPrimaryKey())) . "\nWHERE " . $this->buildWhere($row->getPrimaryKey()));
     // Refresh
     $this->refreshRow($row);
 }