本文整理汇总了PHP中Statistics::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Statistics::save方法的具体用法?PHP Statistics::save怎么用?PHP Statistics::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statistics
的用法示例。
在下文中一共展示了Statistics::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postInsert
public function postInsert($event)
{
$oStatistics = new Statistics();
$oStatistics->setCategoryId($this->getId());
try {
$iPeriod = Period::getCurrentPeriod();
} catch (sfException $e) {
return;
}
if (false !== $iPeriod) {
$oStatistics->setPeriodId($iPeriod);
$oStatistics->save();
}
}
示例2: getFullStatistics
/**
* Returns row by input data
*
* @param integer $iPeriodId
* @param integer $iCategoryId: null
* @return Statistics
*/
public function getFullStatistics($iPeriodId, $iCategoryId = null)
{
$q = Doctrine_Query::create()->select('s.*')->from('Statistics s')->where('s.period_id=?', $iPeriodId)->limit(1);
if (null !== $iCategoryId) {
$q->andWhere('s.category_id=?', $iCategoryId);
} else {
$q->andWhere('s.category_id IS NULL');
}
$stat = $q->fetchOne();
if (!is_object($stat)) {
$stat = new Statistics();
$stat->setPeriodId($iPeriodId);
if (null !== $iCategoryId) {
$stat->setCategoryId($iCategoryId);
}
$stat->save();
}
return $stat;
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Statistics();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Statistics'])) {
$model->attributes = $_POST['Statistics'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: visitStart
/**
* 用户开始进入某页面,添加相关信息
* @param unknown_type $id
*/
public function visitStart($id, $refer)
{
try {
$ip = ip2long(UtilNet::getClientIp());
$model = Statistics::model()->find(array('condition' => 'ip = :ip AND aid = :aid AND refer = :refer AND UNIX_TIMESTAMP( )-starttime<:interval', 'order' => 'id DESC', 'params' => array(':ip' => $ip, ':aid' => $id, ':refer' => $refer, ':interval' => 180)));
UtilHelper::writeToFile($model->attributes);
if ($model) {
$model->endtime = time();
// UtilHelper::writeToFile(array_merge(array('提示'=>'更新'), $model->attributes), 'a+');
if ($model->save()) {
echo $model->id;
}
} else {
$model = new Statistics();
$model->aid = $id;
$model->ip = $ip;
$model->starttime = time();
if (!Yii::app()->user->isGuest) {
$model->uid = Yii::app()->user->id;
}
$model->terminal = $_SERVER['HTTP_USER_AGENT'];
$model->refer = $refer;
// UtilHelper::writeToFile(array_merge(array('提示'=>'新加入数据'), $model->attributes), 'a+');
if ($model->save()) {
echo $model->id;
}
}
UtilHelper::writeToFile(CHtml::errorSummary($model), 'a+');
} catch (Exception $e) {
echo $e->getMessage();
}
}