where('id',766)->first()); //ModelBase::init()->getConnection()->disconnect(); echo "---------------------\n\n"; //$obj->getConnection()->disconnect(); //var_dump(DB::table('datainf_log')->where('id',766)->first()); /* $sql = "select * from datainf_log where id in (766,767) "; $pdo = ModelBase::init()->getConnection()->getPdo(); foreach ($pdo->query($sql ) as $row) { print_r($row); //你可以用 echo($GLOBAL); 来看到这些值 } */ /* try{ ModelBase::beginTransaction(); $model = new \App\Http\Model\StZqResult(); $ret = $model->where(['id'=>4314])->first(); print_r($ret); ModelBase::commit(); }catch (\Exception $e){ echo $e->getMessage(); ModelBase::rollBack(); } $model = new App\Lib\TestModel(); $model->name = 'name_'.mt_rand(1000,99999) ; $model->sex = '男'; $model->age = mt_rand(10,50); $ret = $model->save(); print_r([$ret,$model->toArray()]); */ function getIds($type, $match_id, $game_code = '') { $return = []; if ($type == 1) { $ret = DB::table('money_buy_simplex')->where(['match_id' => $match_id])->get(); if ($ret) { foreach ($ret as $val) { $return[] = $val->order_id; } } return $return; } else { $ret = DB::table('money_buy_str')->leftJoin('money_buy_match', 'money_buy_match.batch_id', '=', 'money_buy_str.batch_id')->where(['money_buy_match.match_id' => $match_id, 'money_buy_match.game_code' => $game_code])->get(); if ($ret) { foreach ($ret as $val) { $return[] = $val->order_id; } } return $return; } } $ids = getIds(1, 483, 'zg'); echo "ids_len:" . count($ids) . "\n"; function request_post($url = '', $param = '') { if (empty($url) || empty($param)) { return false; } $postUrl = $url; $curlPost = $param; $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch);//运行curl curl_close($ch); return $data; } $data = [ 'token' => 'O9Z8zK15629128605d28285cb15dc', 'order_ids' => implode(",", $ids), 'bettype' => 1, 'settype' => 2, 'game_code' => 'zq', 'match_id' => 483, 'change_status' => 1 ]; $ret = request_post('http://192.168.2.220:9094/Settelement', $data); echo "返回:" . print_r($ret, true) . "\n\n"; /* $str = ''; $arr = json_decode($str,true); $arr2 = json_decode( $arr['0']['data'] ,true); foreach ($arr2 as $val){ print_r($val); echo "\n\n"; } */