Craft\RetourService::incrementStatistics PHP Méthode

incrementStatistics() public méthode

public incrementStatistics ( $url, $handled = false )
$url The 404 url
    public function incrementStatistics($url, $handled = false)
    {
        $handled = (int) $handled;
        $url = substr($url, 0, 255);
        $referrer = craft()->request->getUrlReferrer();
        if (is_null($referrer)) {
            $referrer = "";
        }
        /* -- See if a stats record exists already */
        $result = craft()->db->createCommand()->select('*')->from('retour_stats')->where('redirectSrcUrl =' . craft()->db->quoteValue($url))->queryAll();
        if (empty($result)) {
            $stats = new Retour_StatsRecord();
            $stats->redirectSrcUrl = $url;
            $stats->referrerUrl = $referrer;
            $stats->hitCount = 1;
            $stats->hitLastTime = DateTimeHelper::currentUTCDateTime();
            $stats->handledByRetour = $handled;
            $stats->save();
        } else {
            /* -- Update the stats table */
            foreach ($result as $stat) {
                $stat['hitCount'] = $stat['hitCount'] + 1;
                $stat['hitLastTime'] = DateTimeHelper::currentTimeForDb();
                $stat['referrerUrl'] = $referrer;
                $result = craft()->db->createCommand()->update('retour_stats', array('hitCount' => $stat['hitCount'], 'hitLastTime' => $stat['hitLastTime'], 'handledByRetour' => $handled, 'referrerUrl' => $stat['referrerUrl']), 'id=:id', array(':id' => $stat['id']));
            }
        }
    }