查詢七日內活躍用戶數
~~~
<?php
namespace app\index\model;
use app\common\model\RemoteModel;
use think\Db;
use think\Log;
class DCharacter extends RemoteModel
{
/**
* 等級活躍角色ID計算
*
* @param int $level 等級
* @return int 等級流失人數
*/
public function doLevelCountActive($level, $active_days_scope)
{
$map['datediff(now(),lastonlogintime)'] = array('elt', 7);
$map['level'] = $level;
$count = self::where($map)->count();
return $count;
}
~~~