UserActionModel.class.php 856 Bytes
<?php
/**
 * Created by PhpStorm.
 * User: tangxingguo
 * Date: 2017/4/12
 * Time: 10:32
 */
namespace Common\Model;

class UserActionModel extends AbstractModel
{

    // 构造方法
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取用户行为总数
     * @author tangxingguo
     * @param string $uid 用户ID
     * @param string $action_key 行为key
     * @return int
     */
    public function countByActionKey($uid, $action_key)
    {
        $sql = "SELECT COUNT(distinct data_id) FROM  __TABLE__ WHERE `uid` = ? AND `action_key` = ? AND `domain` = ? AND status < ?";

        $params = [
            $uid,
            $action_key,
            QY_DOMAIN,
            $this->get_st_delete(),
        ];

        $count = $this->_m->result($sql, $params);
        return intval($count);
    }
}