1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- require_once 'DB_PDO.class.php';
- require_once 'TBK.class.php';
- require_once 'conf.class.php';
- define("KEYURL","https://item.taobao.com/item.htm?id=");
- /**
- * 更新优选商品剩余数量数据
- */
- #设置时区
- date_default_timezone_set('PRC');
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- $sql = " select goods_id from youxuan_goods order by id desc limit 200";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute();
- $goods = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $total_num = 0;
- $update_num = 0;
- foreach( $goods as $k=>$v ){
- $total_num++;
- $keyword = KEYURL.$v['goods_id'];
- $result = TBK::search( $keyword );
- if( !isset($result->commission_rate )) continue;
- $commission_rate = $result->commission_rate/100;
- $sql = " update goods set commission_rate = :commission_rate where goods_id = :goods_id ";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute(array(':commission_rate'=>$commission_rate,':goods_id'=>$v['goods_id']));
- $res = $stmt->rowCount();
- if($res){
- $update_num++;
- echo "\n\n更新成功:".$res;
- var_dump($v['goods_id']);
- }
- //if($total_num == 3) break;
- }
- echo "\n总共".$total_num."条数据";
- echo "\n成功更新".$update_num."条数据";
|