解析csv并输入到mysql

时间:2013-12-01 17:29:54

标签: php mysql csv

        while(($data = fgetcsv($handle,0,",")) !== FALSE){
            $num = count($data);
                $sql = "INSERT INTO `calendar` (`service_id`, `sunday`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `start_date`, `end_date`) VALUES ('" . $data[0] . "','" . $data[1] . "','" . $data[2] . "','" . $data[3] . "','" . $data[4] . "','" . $data[5] . "','" . $data[6] . "','" . $data[7] . "','" . $data[8] . "','" . $data[9] . "');";
                $collect .= $sql;
                $count = count(explode(";",$collect));
                if($count > 500){
                    $mysql->multi_query($collect);
                    $collect = '';
                    $count = 0;
                }
            $row++;
        }

我正在解析csv并收集查询,如果它超过500提交到sql server 但是multi_query只运行一次为什么?

0 个答案:

没有答案