CommentModel.class.php 754 Bytes
<?php
/**
 * 培训评价表
 * @author: houyingcai
 * @email:    594609175@qq.com
 * @date :  2017-08-29 16:06:33
 * @version $Id$
 */

namespace Common\Model;

class CommentModel extends AbstractModel
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 更新点赞量
     * @author wanghuan
     *
     * @param int $c_id 评论id
     * @param int $type 更新类型:0=加1,1=减1
     *
     * @return bool
     */
    public function update_likes($c_id, $type)
    {
        // 减1
        if ($type) {
            return $this->_m->where('c_id=' . $c_id)->setDec('c_likes', 1);
        } else { // 加1
            return $this->_m->where('c_id=' . $c_id)->setInc('c_likes', 1);
        }
    }
}