Ejemplo n.º 1
0
 public function increment($entryId)
 {
     // check if this action should be ignored
     if ($this->_ignoreAction()) {
         return;
     }
     // get the record from the database w/ the attribute of the passed in entry ID
     $entryCountRecord = EntryCountRecord::model()->findByAttributes(array('entryId' => $entryId));
     // if the record exists, then increment the count
     if ($entryCountRecord) {
         $entryCountRecord->setAttribute('count', $entryCountRecord->getAttribute('count') + 1);
     } else {
         $entryCountRecord = new EntryCountRecord();
         $entryCountRecord->entryId = $entryId;
         $entryCountRecord->count = 1;
     }
     // save the record in the database
     $entryCountRecord->save();
 }
Ejemplo n.º 2
0
 /**
  * Increment count
  *
  * @param int $entryId
  */
 public function increment($entryId)
 {
     // check if action should be ignored
     if ($this->_ignoreAction()) {
         return;
     }
     // get record from DB
     $entryCountRecord = EntryCountRecord::model()->findByAttributes(array('entryId' => $entryId));
     // if exists then increment count
     if ($entryCountRecord) {
         $entryCountRecord->setAttribute('count', $entryCountRecord->getAttribute('count') + 1);
     } else {
         $entryCountRecord = new EntryCountRecord();
         $entryCountRecord->setAttribute('entryId', $entryId);
         $entryCountRecord->setAttribute('count', 1);
     }
     // save record in DB
     $entryCountRecord->save();
 }