You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.8 KiB
PHTML

2 years ago
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2016/9/28
* Time: 19:16
*/
namespace Admin\Model;
use Think\Model;
class MsgModel extends Model{
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix ='tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 发送站内信
* @param array $user_id 用户id
* @param string $content 内容
* @param int $type 类型 1后台
* @param int $status 状态 -1删除 1已读 2未读
* @return bool|string
*/
public function sendMsg($user_id=array(),$content="",$type=1,$status=2){
foreach($user_id as $value){
$data[] = array(
'user_id' => $value['id'],
'content' => $content,
'type' => $type,
'status' => $status,
'create_time' => time(),
);
}
return $this->addAll($data);
} public function sendMsg2($user_id=array(),$content="",$sdk_version=1,$game_id=0,$type=1,$status=2){ foreach($user_id as $value){ $data[] = array( 'user_id' => $value['id'], 'content' => $content, 'type' => $type, 'status' => $status, 'create_time' => time(), 'sdk_version'=>$sdk_version, 'game_id' =>$game_id, ); } return $this->addAll($data); }
}