Doctrine Migration is only loading one record from CSV upload
===

I am working in symfony 1.4 and Doctrine using a migration to upload data into a database. 

I have a CSV file that I am trying to batch load into the sfGuardUser table, and also match the user id with the sfGuardUserGroup group id, and load that into the sf_guard_user table.

When I run the migration, it is only loading the first record from the CSV. The record that loads looks formatted correctly(building the username and dates). 

I tested the code before putting it into the migration, and it worked correctly.

Do I have a syntax eror here, or is it not set up to loop correctly?

Maybe I have just bungled it up entirely.

**PHP**

        public function up()
          {
    
        	  $fieldseparator = ",";
        	  $lineseparator = "\n";
        	  $csvfile = "web/uploads/batchUpload.csv";
        	  
        	  $file = fopen($csvfile,"r");
        	  $size = filesize($csvfile);
        	  
        	  $csvcontent = fread($file,$size);
        	  
        	  fclose($file);
        	  
        	  $lines = 0;
        	  $queries = "";
        	  $linearray = array();
        	  
        	  foreach(explode($lineseparator,$csvcontent) as $line) {
        	  	  
        		  //Clean it up
        		  $lines++;	  
        		  $line = trim($line," \t");	  
        		  $line = str_replace("\r","",$line);	   
        		  $line = str_replace("'","\'",$line);  
        		  $linearray = explode($fieldseparator,$line);
        		  
        		  //build username
        		  if (!$linearray[3]) {
        			  $username = $linearray[0];
        			  $username = substr($linearray[0], 0, 1);
        			  $username .= $linearray[1];
        			  $username = strtolower($username);
        			  $linearray[3] = $username;
        		  }
        		  
        		  //add sha1 algorithm
        		  if (!$linearray[4]) {
        			  $linearray[4] = "sha1";
        		  }
        		  
        		  //add is_active
        		  if(!$linearray[7]) {
        			  $linearray[7] = "1";
        		  }
        		  
        		  //add current date to login, created and updated
        			  $now = getdate();			  
        			  if ($now['mday'] < 10) {
        		          $now['mday'] = str_pad($now['mday'], 2, "0", STR_PAD_LEFT);
        			  }			  
        			  if ($now['hours'] < 10) {
        			  $now['hours'] = str_pad($now['hours'], 2, "0", STR_PAD_LEFT);
        			  }		  
        			  if ($now['minutes'] < 10) {
        			  $now['minutes'] = str_pad($now['minutes'], 2, "0", STR_PAD_LEFT);
        			  }		  
        			  if ($now['seconds'] < 10) {
        			  $now['seconds'] = str_pad($now['seconds'], 2, "0", STR_PAD_LEFT);
        			  }
        			  $linearray[10] = $now['year']. "-" .$now['mon']. 
                              "-".$now['mday']. ".$now['hours'].":".$now['minutes'].":"
                              .$now['seconds'];
        			  $linearray[11] = $now['year']. "-" .$now['mon']. 
                              "-".$now['mday']. " ".$now['hours'].":".$now['minutes'].
                              ":".$now['seconds'];
        		  
        		  
        	     //load up sql	
                 $linemysql = implode("','",$linearray);	
        	     $conn = Doctrine_Manager::getInstance()->connection();  
        	     $query = "INSERT INTO sf_guard_user VALUES ('', '$linemysql');";
        
        	     //$queries .= $query . "\n";	
        	     $conn->execute($query);
        			  
        	     //Add userID to group table
        	     $conn = Doctrine_Manager::getInstance()->connection();  
        	     $getFirstID = Doctrine::getTable('sfGuardUser')->orderBy('id DESC')
                      ->limit(1)->execute();
        	     $id = $getFirstID['id'];
        	     $query = "INSERT INTO sf_guard_user_group ('$id', 5, '$linearray[10]',          '$linearray[11]');";
        	     $conn->execute($query);
        	     $query = "INSERT INTO sf_guard_user_group ('$id', 14, '$linearray[10]', '$linearray[11]');";
        	     $conn->execute($query);
        	}// close foreach split
    }  