public static function logHit($link, $ref) { // create or update log $existing = FourOhFourLog::get()->filter(array('Referrer' => $ref, 'Link' => $link))->first(); if ($existing) { $existing->Count = $existing->Count + 1; $existing->write(); } else { $log = new FourOhFourLog(); $log->Referrer = $ref; $log->Link = $link; $log->Count = 1; $log->write(); } }