search
Homephp教程php手册最新县及县以上行政区划代码(截止2014年10月31日)

采集自国家统计局
http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201504/t20150415_712722.html
有需要的同学自行下载附件,分割入库
文件格式如下
110000,北京市###110100,市辖区###110101,东城区###110102……

数据库方面CREATE TABLE `think_region` (<br>   `id` mediumint(6) unsigned NOT NULL DEFAULT '0',<br>   `pid` mediumint(6) unsigned NOT NULL DEFAULT '0',<br>   `name` varchar(100) NOT NULL DEFAULT '',<br>   `type` tinyint(1) NOT NULL DEFAULT '0',<br>   PRIMARY KEY (`id`),<br>   KEY `type` (`type`)<br> ) ENGINE=MyISAM DEFAULT CHARSET=utf8控制器方面        $DB = M('Region');<br>         $file = './code.txt';<br>         $content = file_get_contents($file);<br>         $content = think_s2a($content, '###');<br>         $i=0;$addall=array();<br>         foreach ($content as $v) {<br>             $data = think_s2a($v);<br>             switch (true) {<br>                 case (preg_match('/\d{2}0000/', $data[0])):<br>                     $pid = 0;<br>                     $type = 0;<br>                     break;<br>                 case (preg_match('/\d{4}00/', $data[0])):<br>                     $pid = substr($data[0], 0, 2) . '0000';<br>                     $type = 1;<br>                     break;<br>                 default:<br>                     $pid = substr($data[0], 0, 4) . '00';<br>                     $type = 2;<br>             }<br>             $add = array(<br>                 'id'   => $data[0],<br>                 'pid'  => $pid,<br>                 'name' => $data[1],<br>                 'type' => $type,<br>             );<br>             $rules = array(<br>                 array('id', 'require','id必须'),<br>                 array('pid', 'require','pid必须'),<br>                 array('name', 'require','neme必须'),<br>                 array('type', array(0,1, 2), '类型范围', 1, 'in', 1),<br>                 array('id', '', '该地区已录入', 1, 'unique', 1),<br>             );<br>             if ($DB->validate($rules)->create($add, 1)) {<br>                 $addall[$i]=$DB->data();<br>                 $i++;<br>             }<br>         }<br>         $DB->addAll($addall);

附件 地区.zip ( 20.91 KB 下载:106 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool