7日間の記録に署名し、切断して再開します.
1996 ワード
//
public function member_Sign(){
$last_sign = $this->models('member')->get_last_sign();
$sign_count = $last_sign ? $last_sign['sign_count'] : 0;
if ($sign_count > 0 && date('Y-m-d', $last_sign['sign_time']) == date('Y-m-d')) {
$this->msg(1, $clock,' ');
}
$next_count = $sign_count + 1;
$next_count > 7 and $next_count = 0;
$this->db->insert(SITE_ID . '_member_sign', array(
'uid' => $this->uid,
'title' => ' '.$this->member['name'].' ',
'status' => 1,
'sign_time' => SYS_TIME,
'sign_count' => $next_count,
'score' => ($sign_count + 1)*5
));
$id = $this->db->insert_id();
$jifen = ($sign_count + 1) * 5;
//
$this->db->set('experience','experience+'.$jifen,false)->where('uid',$this->uid)->update('member');
$id > 0 ? $this->msg(0,' ') : $this->msg(1,' -->');
}
MODELS内記録
//
public function get_last_sign() {
return $this->db->select("uid,status,sign_count,sign_time")
->where('uid', $this->uid)
->where('sign_time >=', strtotime('-1 day today'))
->where('status', 1)
->order_by('sign_time desc')
->limit(1)
->get(SITE_ID . '_member_sign')
->row_array();
}