/** * 有消息时触发该方法 * @param int $client_id 发消息的client_id * @param string $message 消息 * @return void */ public static function onMessage($client_id, $message) { $db = \Lib\Db::instance('tc504'); $nowtime = idate("U"); $ok = "right"; $error = "error"; $sqlok = "sql right!"; $sqlerror = "sql error!"; if ($message[0] == '{') { $message = JsonProtocol::decode($message); $sqldidian = $message['ID']; $sqlshidu = $message['humidity']; $sqlwendu = $message['temperature']; $insert_id = $db->insert('wenshidu')->cols(array('didian' => $sqldidian, 'shidu' => $sqlshidu, 'wendu' => $sqlwendu, 'time' => $nowtime))->query(); GateWay::sendToClient($client_id, TextProtocol::encode($insert_id)); } else { $message = TextProtocol::decode($message); $commend = trim($message); $ret = $db->select('ui_cardid')->from('tbl_user')->where("ui_cardid = '{$commend}' ")->single(); if ($commend === $ret) { $insert_id = $db->insert('tbl_log')->cols(array('log_card' => $commend, 'log_time' => $nowtime))->query(); if ($insert_id === 1) { GateWay::sendToClient($client_id, TextProtocol::encode($sqlok)); } else { GateWay::sendToClient($client_id, TextProtocol::encode($sqlerror)); } } else { GateWay::sendToClient($client_id, TextProtocol::encode($error)); } } }
public function __Construct() { $this->_store = Store::instance('game'); $this->_db = Db::instance('passport'); $this->_pbMember = new PbMember(); $this->_pbResult = new PbResult(); }
/** * 获取在线数据 * @param null $sid 服务器ID * @return mixed */ public static function getOnline($sid = null) { if (is_null($sid)) { $where = 'WHERE 1=1'; } else { $where = "WHERE s_id = {$sid}"; } $db = Db::instance('passport'); $sql = "SELECT COUNT(*) AS totle FROM `t_online` {$where}"; $result = $db->single($sql); return $result; }
/** * @return mixed */ public static function getServerList() { $store = Store::instance('game'); $db = Db::instance('passport'); $key = "GAME_ZONE_SERVER_LIST"; $serverList = $store->get($key); if ($serverList) { return $serverList; } $sql = "SELECT s_id,s_name,s_type,s_ip FROM `t_server`\n WHERE s_status=1\n ORDER BY s_id ASC"; $result = $db->query($sql); if ($result) { $store->set($key, $result); } return $result; }
public static function report($data) { $db = Db::instance('passport'); $result = $db->insert('t_statistic')->cols($data)->query(); return $result; }
public function __Construct() { $this->_db = Db::instance('passport'); $this->_pbResult = new PbResult(); }
public function __Construct() { $this->_store = Store::instance('game'); $this->_db = Db::instance('passport'); }