Inserting For each? |
[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.
[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.
[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()
[eluser]Glazz[/eluser]
No problem, you can make it "more cleaner" Controller: Code: function insert() Model: Code: function updateAanwezigheid()
[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)
[eluser]Dizza[/eluser]
CroNIX thank you! I will use that one! Way faster ![]() Glazz thank you for helping me out this night! Bye! |
Welcome Guest, Not a member yet? Register Sign In |