我有一个使用Yii框架编写的php应用程序。
实际上给我一个问题的控制器,获取一个csv文件,打开它以读取内容并为每个csv文件行添加/更新数据库记录。
public function actionGetCSVArticleData(){
try {
$file = fopen("C:\\wamp\\www\\ps\\articoli.csv","r");
$result ="";
$i=0;
while (($data = fgetcsv($file, 1000, ";")) !== FALSE)
{
$result[$i++]= $data;
}
for($j=1;$j<count($result);$j++){
for($k=0;$k<count($result[$j]);$k++){
$tempData = $result[$j];
$articleMgmt = new ArticleMgmt();
if(isset($tempData[0]) && isset($tempData[3])) {
$articleMgmt->code=trim($tempData[0]);
$articleMgmt->customer_code=trim($tempData[3]);
} else {
$articleMgmt->code=null;
}
if($articleMgmt->code!=null){
$tCode = $this->isArticleExist($articleMgmt->code, $articleMgmt->customer_code);
if($tCode !=-1){
$updateArticle = ArticleMgmt::model()->findByPk($tCode);
$this->updateArticle($updateArticle,$tempData);
}else{
$this->updateArticle($articleMgmt,$tempData);
}
}
}
}
fclose($file);
$count = ArticleMgmt::model()->count();
$articleData = ArticleMgmt::model()->findAll();
$result = array('data' => $articleData, 'total' => $count);
echo CJSON::encode($result);
} catch(Exception $e){
echo CJSON::encode(array("success" => false, 'message' => $e->getMessage()));
}
}
问题是30秒后对控制器方法的调用被取消,它不处理整个文件而只处理第一部分。考虑到我在文件中有大约40,000行,并且在大约7800之后它会中断。
奇怪的是,我已经检查并修改了php.ini而没有任何结果:
max_execution_time = 600
max_input_time = 120
memory_limit = 256 Mb
答案 0 :(得分:0)
你确定吗
你编辑正确的php.ini,
在phpinfo你有
max_execution_time=600
你改变后重启了apache吗?