public function getVisitorId($sessionId)
{
$urlId = $this->getUrlId($this->getRequestUri(), $this->getReferer());
$select = new Select();
$select->from(array('lv' => $this->name))->columns(array('id'))->where->equalTo('session_id', $sessionId)->equalTo('http_user_agent', $this->getUserAgent())->equalTo('remote_addr', $this->getRemoteAddr());
$visitorId = $this->fetchOne($select);
if (empty($visitorId)) {
$insert = new Insert();
$insert->into('log_visitor')->values(array('session_id' => $sessionId, 'http_user_agent' => $this->getUserAgent(), 'http_accept_charset' => $this->getAcceptCharset(), 'http_accept_language' => $this->getAcceptLanguage(), 'server_addr' => $this->getServerAddr(), 'remote_addr' => $this->getRemoteAddr()));
$this->execute($insert);
$visitorId = $this->getLastInsertId('log_visitor');
}
$insert = new Insert();
$insert->into('log_url')->values(array('visit_at' => new Expression('NOW()'), 'log_url_info_id' => $urlId, 'log_visitor_id' => $visitorId));
$this->execute($insert);
return $visitorId;
}