SearchAction::setNewcount PHP Method

setNewcount() public method

public setNewcount ( $weiba_id, $num = 1 )
    public function setNewcount($weiba_id, $num = 1)
    {
        $map['weiba_id'] = $weiba_id;
        $time = time();
        $weiba = M('weiba')->where($map)->find();
        if ($weiba['new_day'] != date('Y-m-d', $time)) {
            M('weiba')->where($map)->setField('new_day', date('Y-m-d', $time));
            M('weiba')->where($map)->setField('new_count', 0);
        }
        if ($num == 0) {
            M('weiba')->where($map)->setField('new_count', 0);
        }
        if ($num > 0) {
            M('weiba')->where($map)->setField('new_count', (int) $num + (int) $weiba['new_count']);
        }
        return true;
    }