首页 > 数据库技术 > 详细

初始化地区到数据库

时间:2018-07-26 23:16:37      阅读:286      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="city.js"></script>

<script>
var i = 0;
var j = 0;
var k = 0;
var sqlstring="";
for( i = 0; i < cityData.length;i++ ){
  // console.log(cityData[i].name,cityData[i].id);
   // 市
   sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(0,‘" + cityData[i].name +"‘,0,"+cityData[i].id+");";
  console.log(sqlstring);
  
   var cityList = cityData[i].cityList;
   for( j = 0; j < cityList.length;j++ ){
       
       //console.log("=============>",cityList[j].name,cityList[j].id);
	   sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(1,‘" + cityList[j].name +"‘,"+cityList[j].pid+","+cityList[j].id+");";
       console.log(sqlstring);
  
	   // 区
	   var districtList =  cityList[j].districtList;
	   for(k = 0; k < districtList.length;k++ ){
	     // console.log("++++++++++++++++++++++>",districtList[k].name,districtList[k].id);
		  sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(2,‘" + districtList[k].name +"‘,"+districtList[k].pid+","+districtList[k].id+");";
          console.log(sqlstring);
	   }
   }
   
}
console.log("count=",i);
</script>

</body>
</html>

  

初始化地区到数据库

原文:https://www.cnblogs.com/tinyos/p/9374791.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!