20,359
社区成员
发帖
与我相关
我的任务
分享
MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Error ) [1] => Array ( [sql] => INSERT INTO `tour`.`gd_goods`(goods_id, cat_id, goods_sn, goods_name, goods_name_style, click_count, brand_id, provider_name, goods_number, goods_weight, market_price, shop_price, promote_price, promote_start_date, promote_end_date, warn_number, keywords, goods_brief, goods_desc, goods_thumb, goods_img, original_img, is_real, extension_code, is_on_sale, is_alone_sale, is_shipping, integral, add_time, sort_order, is_delete, is_best, is_new, is_hot, is_promote, bonus_type_id, last_update, goods_type, seller_note, give_integral, rank_integral, suppliers_id, is_check)VALUES ('', '0', '', '深圳最新COCO PARK大型購物中心一天團', '', '0', '', '0', '1', '', '0', '79', '89', '', '2012/10/21 0:00:00', '', '', '', '', '', '', '', '1', '2905', '0', '0', '0', '', '', '', '', '0', '0', '0', '0', '', '', '0', '0', '', '', '', '') ) [2] => Array ( [error] => Duplicate entry '0' for key 1 ) [3] => Array ( [errno] => 1062 ) )
//团的编号id
$good_id = $data['Id'];
echo $good_id."\n\r";// 输出没有数据;奇怪,怎么赋值传不过去?
<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
require_once(ROOT_PATH . '/' . ADMIN_PATH . '/includes/lib_goods.php');
header ("Content-Type:text/html; charset=UTF-8");
$url = 'http://58.61.153.173/dataport/GetAllTourInfo.ashx';
$host=array('user: gdtourserviceuser','password: gdtour!123.@983_???000');
$ch = curl_init();
set_time_limit(0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$host);
$output = curl_exec($ch);
if ($output === FALSE) {
echo "cURL Error: " . curl_error($ch);
}
curl_close($ch);
$obj=json_decode($output,TRUE);
//取到站外传来的数据,循环插入本地数据库
foreach($obj['data'] as $data)
{
//团的编号id
$good_id = $data['Id'];
//约定extension_code是团de线id
$extension_code= $data['TourId'];
//线路id
$cat_id = (int)$data['Catalog'];
//线路编号
$good_sn = (string)$data['ProductCode'];
//线路名称
$goods_name = $data['ProductName'];
//行程天数
$goods_number= $data['ProcessDays'];
//行程简介
$goods_bref = $data['ProcessResume'];
//约定 shop_price 是平日价,promote_price是假日价,market_prices是nomal_price
$shop_price = (float)$data['WorkDayPrice'];
$market_price = (float)$data['NormalPrice'];
$promote_price =(float)$data['WeekdayPrice'];
//是否是自营线路,代理线路
$provider_name= $data['BizCatalog'];
//散团,包团
$goods_type = $data['Type'];
//0-系列线,1-另写线
$seller_note = $data['RDCatalog'];
//出发时间
$goods_brief = '';
$promote_end_date =(string)$data['StartDate'];
$click_count = 0;
$goods_name_style ='';
$brand_id = '';
$is_promote = 0;
$promote_start_date = '';
$goods_img = '';
$goods_thumb = '';
$original_img = '';
$keywords = '';
$warn_number = '';
$integral = '';
$goods_weight = '';
$give_integral = '';
$is_best = 0;
$is_new = 0;
$is_hot = 0;
$is_on_sale = 0;
$is_alone_sale = 0;
$is_shipping = 0;
$goods_desc = '';
$rank_integral = '';
$suppliers_id ='';
$is_real = 1;
$is_check = '';
$num = 1;
$sql = "INSERT INTO ". $GLOBALS['ecs']->table('goods')."(goods_id, cat_id, goods_sn, goods_name, goods_name_style, click_count, brand_id, provider_name, goods_number, goods_weight, market_price, shop_price, promote_price, promote_start_date, promote_end_date, warn_number, keywords, goods_brief, goods_desc, goods_thumb, goods_img, original_img, is_real, extension_code, is_on_sale, is_alone_sale, is_shipping, integral, add_time, sort_order, is_delete, is_best, is_new, is_hot, is_promote, bonus_type_id, last_update, goods_type, seller_note, give_integral, rank_integral, suppliers_id, is_check)". "VALUES
('$goods_id', '$cat_id', '$goods_sn', '$goods_name', '$goods_name_style', '$click_count', '$brand_id', '$provider_name', '$goods_number', '$goods_weight', '$market_price', '$shop_price', '$promote_price', '$promote_start_date', '$promote_end_date', '$warn_number', '$keywords', '$goods_brief', '$goods_desc', '$goods_thumb', '$goods_img', '$original_img', '$is_real', '$extension_code', '$is_on_sale', '$is_alone_sale', '$is_shipping', '$integral', '$add_time', '$sort_order', '$is_delete', '$is_best', '$is_new', '$is_hot', '$is_promote', '$bonus_type_id', '$last_update', '$goods_type', '$seller_note', '$give_integral', '$rank_integral', '$suppliers_id', '$is_check')";
$GLOBALS['db']->query($sql);
}
echo "insert sucess!\n\r";
?>