Help w/ updating backend db with .csv file |
[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; Any help or advice is greatly appreciated. Thank you.
[eluser]pistolPete[/eluser]
[quote author="puddles" date="1255289050"]1) Understanding where the logic goes - in the view or in the controller?[/quote] Have a look at the user guide: http://ellislab.com/codeigniter/user-gui...w/mvc.html There should be little to no logic in the view! [quote author="puddles" date="1255289050"]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?[/quote] If the array is associative, it's as simple as Code: $this->db->insert($array); [quote author="puddles" date="1255289050"]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?[/quote] I don't know if I understood you correctly, but you can serialize an array and save the result to the database. http://php.net/manual/en/function.serialize.php |
Welcome Guest, Not a member yet? Register Sign In |