Ajeet
Ajeet

Reputation: 49

Zend framework - insert less than 500 rows only

I'm using Zend framework with Mysql. My application loads the data from a csv file into the mysql database. The table has two columns (id and name). The application uses file_get_contents to read the csv file and uses $this->insert($data) of Zend_Db_Table. The file has exactly two columns similar to the table.

The problem I'm facing is, while inserting data, it inserts around 500 rows only. Remaining rows are not inserted in database. No errors are shown in the browser and the application works like nothing happened. I tried with different data but the problem is the same.

$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++; 

The uploadborrower function simply makes array $data and insert by using this->insert($data) – A

Can anyone help me to find where the problem is and how to solve the problem?

Upvotes: 1

Views: 306

Answers (2)

Ajeet
Ajeet

Reputation: 49

$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++; 

Upvotes: 1

Alberto Arena
Alberto Arena

Reputation: 343

Can it be a problem of timeout? If the CSV is massive, it can happen.

Try:

set_time_limit(0);

before to execute your code.

Upvotes: 1

Related Questions