Example #1
0
 function logDownload(User $user, File $file, $ip = '')
 {
     $begin_date = $this->getDi()->dateTime;
     $begin_date->modify('-' . self::TOLERANCE . ' seconds');
     $begin_date = $begin_date->format('Y-m-d H:i:s');
     $count = $this->countBy(array('user_id' => $user->pk(), 'file_id' => $file->pk(), 'dattm' => '>' . $begin_date));
     if (!$count) {
         $this->insert(array('user_id' => $user->pk(), 'file_id' => $file->pk(), 'dattm' => $this->getDi()->sqlDateTime, 'remote_addr' => $ip));
     }
 }