Welcome Guest, Not a member yet? Register   Sign In
Help w/ updating backend db with .csv file
#1

[eluser]puddles[/eluser]
Hi,

I'm a novice programmer, and need help. I've used the file uploading class from codeigniter to upload a hockey player statistics file, in .csv format. Now, I'd like to somehow read that file, parse it, and update a backend mysql db with each row of the data.

I'm having trouble with some very basic things:

1) Understanding where the logic goes - in the view or in the controller?
2) What is the easiest way to take an array of a row's data (which has 31 fields), and insert it into a database using ActiveRecord?
3) Is there a way to add array items to each row so that I can supplement the data that was provided in the actual .csv file?

Code:
$row = 1;
$handle = fopen('D:/xampp/htdocs/newhphq/daily_stats/NHL2010GoldPlayers_100809.reg_.csv', 'r');
    // iterate through file one row at a time until receive FALSE    
    while (($rawdata = fgetcsv($handle,",")) !== FALSE)
    {
            
    // how do I add new items to the array

            
    // how do I use ActiveRecord to insert array into database

                
    // increment row counter to next row
    $row++;
                
       //
                                    
}
fclose($handle);

Any help or advice is greatly appreciated. Thank you.


Messages In This Thread
Help w/ updating backend db with .csv file - by El Forum - 10-11-2009, 08:24 AM
Help w/ updating backend db with .csv file - by El Forum - 10-11-2009, 09:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB