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.
84 lines
1.9 KiB
PHTML
84 lines
1.9 KiB
PHTML
5 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by PhpStorm.
|
||
|
* User: xmy 280564871@qq.com
|
||
|
* Date: 2017/3/28
|
||
|
* Time: 16:41
|
||
|
*/
|
||
|
|
||
|
namespace Mobile\Model;
|
||
|
use Think\Model;
|
||
|
|
||
|
class ServerModel 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 $game_id
|
||
|
* @return mixed
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function getOpenServer($game_id){
|
||
|
$map['game_id'] = $game_id;
|
||
|
$map['show_status'] = 1;
|
||
|
$data = $this->field('*')->order("start_time desc")->where($map)->select();
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取区服表
|
||
|
* @param $map
|
||
|
* @param int $p
|
||
|
* @return mixed
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function getServerLists($map,$p=1){
|
||
|
$page = intval($p);
|
||
|
$page = $page ? $page : 1; //默认显示第一页数据
|
||
|
$row = 10;
|
||
|
$map['show_status'] = 1;
|
||
|
$data = $this->table("tab_server as ser")
|
||
|
->field('server_name,start_time,ser.game_name,sor.pack_name,ser.game_id')
|
||
|
->join("left join tab_game_source as sor on sor.game_id = ser.game_id")
|
||
|
->where($map)
|
||
|
->order("start_time")
|
||
|
->page($page,$row)
|
||
|
->select();
|
||
|
foreach ($data as $key => $val){
|
||
|
$data[$key]['down_url'] = GameModel::generateDownUrl($val['game_id']);
|
||
|
}
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取区服列表通过游戏
|
||
|
* @param integer $game_id 游戏编号
|
||
|
* @author 鹿文学
|
||
|
*/
|
||
|
public function get_server_list_by_game($game_id=0) {
|
||
|
if(is_numeric($game_id) && $game_id > 0) {
|
||
|
|
||
|
$lists = $this->field('id as server_id,server_name')->where(['game_id'=>$game_id,'show_status'=>1])->select();
|
||
|
|
||
|
return $lists;
|
||
|
} else {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|