function itemUpdate($id, $data = array()) { $su = new ItemInfo(); $condition = '`id`=' . $id; $r = $su->iteminfo_update($data, $condition); return mysql_fetch_assoc($r); }
<?php //error_reporting(0); require_once '/var/www/git/application/models/data/ItemInfo.php'; $obj = new ItemInfo(); $arr = array('stockNum' => 0); $ids = array(); $r = $obj->ItemInfo_select($arr, 1000); while ($re = mysql_fetch_array($r)) { $id = $re['id']; $ids[$id] = rand(10, 50); } foreach ($ids as $id => $water) { $arr = array('stockNum' => $water); $condition = 'id =' . $id; $obj->iteminfo_update($arr, $condition); }
if ($count == 50) { $group++; $count = 0; continue; } } //请求内容 $token = 'mengchun'; $appkey = '23182322'; $secret = '0bfab4f09119f33ebabb8348d314ceeb'; $tb_result = null; if (!is_null($re)) { foreach ($re as $key => $value) { $ids = implode(',', $value); $url = 'http://nuannuangouwu-1.wx.jaeapp.com/?token=' . $token . '&appkey=' . $appkey . '&secret=' . $secret . '&ids=' . $ids; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取数据返回 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回 $tb_result = curl_exec($ch); $tb_result_arr = json_decode($tb_result, true); //$tb_result = file_get_contents($url); foreach ($tb_result_arr[items][x_item] as $key => $value) { $arr = array('tb_id' => $value['open_iid'], 'itemPic' => $value['pic_url'], 'itemDiscount' => $value['price'], 'itemPrice' => $value['reserve_price'], 'describe' => $value['title'], 'end_time' => $value['price_end_time']); $limit = 'id = ' . $value['open_id']; $items->iteminfo_update($arr, $limit); } } sleep(10); }