本文整理汇总了PHP中Visitor::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Visitor::model方法的具体用法?PHP Visitor::model怎么用?PHP Visitor::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visitor
的用法示例。
在下文中一共展示了Visitor::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addArticleVisitorInfo
/**
* Add the visitor who have read this blog
* @param int $id
*/
public function addArticleVisitorInfo($id, $interval)
{
$ip = UtilNet::getClientIp();
// echo $ip;
// $qq = new QQWry(long2ip($ip));
// echo $qq->getDetailInfo();
$visitorInfo = Visitor::model()->find('ip = :ip AND aid = :aid', array(':ip' => $ip, ':aid' => $id));
// UtilHelper::dump($visitorInfo->attributes);
if ($visitorInfo) {
$visitorInfo->lasttime = time();
$visitorInfo->times++;
$visitorInfo->alltime .= '|' . time();
$visitorInfo->intervals .= '|' . $interval;
if (!Yii::app()->user->isGuest) {
$visitorInfo->uid = Yii::app()->user->id;
}
UtilHelper::writeToFile($visitorInfo->attributes);
// Yii::app()->end();
try {
$visitorInfo->save();
} catch (Exception $e) {
UtilHelper::dump($e);
}
} else {
$visitorInfo = new Visitor();
$visitorInfo->aid = $id;
$visitorInfo->ip = $ip;
$visitorInfo->lasttime = time();
$visitorInfo->times = 1;
$visitorInfo->intervals = $interval;
if (!Yii::app()->user->isGuest) {
$visitorInfo->uid = Yii::app()->user->id;
}
$visitorInfo->alltime = time();
$visitorInfo->refer = $_SERVER['HTTP_REFERER'];
$visitorInfo->terminal = $_SERVER['HTTP_USER_AGENT'];
UtilHelper::writeToFile($visitorInfo->attributes);
// Yii::app()->end();
if ($visitorInfo->save()) {
// echo "OK";
} else {
// echo "Fail";
}
}
}
示例2: actionHome
public function actionHome($uid)
{
if (Yii::app()->user->isGuest) {
$this->redirect('./index.php?r=user/login');
}
$vhid = $uid;
$user = User::model()->findByPk($uid);
$user->visitor += 1;
$user->save(false);
if ($uid != Yii::app()->user->id) {
$visit = new Visitor();
$visit->uid = Yii::app()->user->id;
$visit->toid = $uid;
$visit->time = time();
$visit->save(false);
}
//活跃用户展示
$yaya = User::model()->findAll(array('order' => 'update_time desc', 'limit' => 16));
//思想展示
$sql = "select * from {{article}} where author_id = {$uid} order by create_time desc limit 0, 20 ";
$sixiang = Article::model()->findAllBySql($sql);
//标签展示
$sq = "select * from {{usertags}} where uid = {$uid} order by create_time desc";
$bq = Usertags::model()->findAllBySql($sq);
//home页面用户关注的丫丫数量
$uf = "select * from {{follow}} where uid={$uid}";
$userfollow = count(Follow::model()->findAllBySql($uf));
//home页面粉丝数量
$fan = "select * from {{follow}} where touid={$uid}";
$fans = count(Follow::model()->findAllBySql($fan));
//访问我的主页的用户展示
$userid = Yii::app()->user->id;
$cs1 = "select *,count(distinct uid) from {{visitor}} where toid={$userid} group by uid order by time desc limit 16";
$fangwenwo = Visitor::model()->findAllBySql($cs1);
$cs2 = "select *,count(distinct toid) from {{visitor}} where uid={$vhid} group by toid order by time desc limit 16";
$visitwho = Visitor::model()->findAllBySql($cs2);
$data = array('user' => $user, 'yaya' => $yaya, 'sixiang' => $sixiang, 'bq' => $bq, 'userfollow' => $userfollow, 'fans' => $fans, 'fangwenwo' => $fangwenwo, 'visitwho' => $visitwho);
$this->render('home', $data);
}
示例3: fmod
echo fmod($i, 2) == 0 ? 'even' : 'odd';
$i++;
?>
" id="<?php
echo $line->id;
?>
">
<td><input type="checkbox" name="id[]" value="<?php
echo $line->id;
?>
" /></td>
<td><?php
echo CHtml::link($line->title, array('archiver/blog', 'id' => $line->id));
?>
(<b><?php
echo count(Visitor::model()->getArticleVisitors($line->id));
?>
</b>)</td>
<td><?php
echo $line->channel->name;
?>
</td>
<td><?php
echo date('m-d h:i', $line->pubdate);
?>
</td>
</tr>
<?php
}
?>
示例4: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Visitor::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}