1

我正在将 Zend 框架与 Mysql 一起使用。我的应用程序将数据从 csv 文件加载到 mysql 数据库中。该表有两列 (idname)。应用程序用于file_get_contents读取 csv 文件并使用 Zend_Db_Table 的 $this->insert($data)。该文件恰好有两列与表类似。

我面临的问题是,在插入数据时,它只插入了大约 500 行。剩余的行不会插入到数据库中。浏览器中没有显示任何错误,应用程序就像什么也没发生一样工作。我尝试了不同的数据,但问题是一样的。

$file = file_get_contents($filename, FILE_USE_INCLUDE_PATH);
$lines = explode("\n", $file);
$i=1;
for($c=1; $c < (count($lines)-1); $c++) {
list($field1, $field2) = explode(",", $lines[$i]);
$borrower= new Application_Model_DbTable_TempB();
$borrower->uploadborrower($field1, $field2); 
$i++; 

uploadborrower 函数只需使用 -A 生成数组 $data 并this->insert($data)插入

谁能帮我找出问题所在以及如何解决问题?

4

2 回答 2

1

会不会是超时的问题?如果 CSV 很大,它可能会发生。

尝试:

set_time_limit(0);

在执行您的代码之前。

于 2012-10-31T11:07:19.387 回答
1
$file = file_get_contents($filename, FILE_USE_INCLUDE_PATH);
$lines = explode("\n", $file);
set_time_limit(0);
$i=1;
for($c=1; $c < (count($lines)-1); $c++) {
list($field1, $field2) = explode(",", $lines[$i]);
$borrower= new Application_Model_DbTable_TempB();
$borrower->uploadborrower($field1, $field2); 
$i++; 
于 2012-11-01T09:21:54.663 回答