public function addGcaty()
{
$obj = M("ServiceCategory");
$file = 'service.txt';
$content = file_get_contents($file);
$array = explode("==", $content);
$len = count($array);
for($i=0;$i<$len;$i=$i+2)
{
$j = $i+1;
$data = array();
$data['parent_id'] = 0;
$data['level'] = 0;
$data['cate_name'] = preg_replace('/\r|\n/', '', $array[$i]);
$bkid = $obj->add($data);
unset($data);
$srdata = explode("\r\n", $array[$j]);
$srdlen = count($srdata);
for($k=1;$k<$srdlen;$k++)
{
$arr = array();
$arr['parent_id'] = $bkid;
$arr['level'] = 1;
$arr['cate_name'] = preg_replace('/\r|\n/', '', $srdata[$k]);
$id = $obj->add($arr);
unset($arr);
}
}
return $bkid;
}