Inserting For each? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Inserting For each? (/showthread.php?tid=52437) Pages:
1
2
|
Inserting For each? - El Forum - 06-11-2012 [eluser]Dizza[/eluser] [quote author="Glazz" date="1339442077"]After you submit your form, try using this code to see what you are exactly getting from the form: Code: var_dump( $this->input->post() ); Code: var_dump( $this->input->post('aanwezigheid') ); Inside the foreach, you place your mysql query, but you need change the values of course, so it will be automatically.[/quote] Haha thanks! Im almost there now My model looks like this now Code: function updateAanwezigheid($data) And my controller Code: function insert(){ When i used the var_dump all data was there but now i get this error, that while im not even updating Code: You must use the "set" method to update an entry. Inserting For each? - El Forum - 06-11-2012 [eluser]Glazz[/eluser] Well like i said, you need to loop the $aanwezigheid array and insert or update your desired records. Code: $this->aanwezigheid_model->updateAanwezigheid($data); My sugestion, in your controller you do the loop and call the model function inside the loop, something like: Code: foreach ( $aanwezigheid as $ID => $value ) And in your model function you just need to do the db->insert thing.. Since i don't understand those functions names and those variables names either, i can't help you much with this. Inserting For each? - El Forum - 06-11-2012 [eluser]Dizza[/eluser] I fixed it! Thanks to you! Lots of thanks, my model now looks like this, just for the people who have the samen problem in the future Code: function updateAanwezigheid() Inserting For each? - El Forum - 06-11-2012 [eluser]Glazz[/eluser] No problem, you can make it "more cleaner" Controller: Code: function insert() Model: Code: function updateAanwezigheid() Inserting For each? - El Forum - 06-11-2012 [eluser]Unknown[/eluser] -- Inserting For each? - El Forum - 06-11-2012 [eluser]CroNiX[/eluser] look into a batch insert. Inserting in a loop is very resource consuming compared to a single query. Code: foreach ( $aanwezigheid as $llID => $aanwezig ) Code: aanwezigheid_model::updateAanwezigheid($data) Inserting For each? - El Forum - 06-11-2012 [eluser]Dizza[/eluser] CroNIX thank you! I will use that one! Way faster Glazz thank you for helping me out this night! Bye! |