Having issue with updating database |
[eluser]ZeroNine[/eluser]
I been trying to stay away from posting up this issue since it seems like such a simple fix but I can't seem to figure it out and I been pulling my hair out with this. Code: function update_invites_table($inv_id,$pid) $pid is an integer and the field invited_pid is set to int(11) but the column will not update with this number. What is sooo odd is that this works: Code: function update_invites_table($inv_id,$pid) Also this works too Code: function update_invites_table($inv_id,$pid) BUT if I do this Code: function update_invites_table($inv_id,$pid) $pid will echo 23 but the column does not update. What can possibly be going on here?
[eluser]InsiteFX[/eluser]
Because update and insert expect an associated array! Code: $data = array( Also you do not need to set the values it will do it.
[eluser]Matalina[/eluser]
@InsiteFX: While you are correct it can take an array, you can use set() to do the same thing. Code: $this->db->set('name', $name); Quote:You may also use the $this->db->set() function described above when performing updates. Taken Straight from documentation. @ZeroNine: Are you sure you are adding the correct data type to the database. is '23' and 23 are not the same.
[eluser]InsiteFX[/eluser]
Sure can using an extra lines of code that are not needed!
[eluser]Matalina[/eluser]
but that isn't what you said. You said it expects an associative array. Not that their code was bloated.
[eluser]ZeroNine[/eluser]
[quote author="InsiteFX" date="1337957062"]Because update and insert expect an associated array! Code: $data = array( Also you do not need to set the values it will do it. [/quote] Yes I actually tried this way first and I had the same problem so I tried $this->db->set().
[eluser]ZeroNine[/eluser]
[quote author="Matalina" date="1337960753"]@InsiteFX: While you are correct it can take an array, you can use set() to do the same thing. Code: $this->db->set('name', $name); Quote:You may also use the $this->db->set() function described above when performing updates. Taken Straight from documentation. @ZeroNine: Are you sure you are adding the correct data type to the database. is '23' and 23 are not the same.[/quote] Thank you for your reply! I changed the database field to VARCHAR to test that way and it still did not work.
[eluser]Matalina[/eluser]
What's be replaced in there? I assume you aren't getting errors. going to ask you a silly question. is the id valid? I'm thinking that it's updating just not updating where you think it is.
[eluser]ZeroNine[/eluser]
I should mention that $pid was first encoded and used as an email confirmation code Example: http://mysite.com/confirm/WXTfrs+=. And then in the controller it was decoded before being sent to the model as $pid. Example: $pid = $this->encrypt->decode($pid_code); Then sent over to the model.. Code: $this->invite_model->update_invites_table($inv_id,$pid);
[eluser]ZeroNine[/eluser]
[quote author="Matalina" date="1337968040"]What's be replaced in there? I assume you aren't getting errors. going to ask you a silly question. is the id valid? I'm thinking that it's updating just not updating where you think it is.[/quote] You are correct, I am not getting any errors. After I run the script, the database field stays empty. Also if I were to manually input any number into the database field through phpmyadmin and then run the script, it will erase it completely and leave it blank or back to 0 depending on if the field is set to VARCHAR or INT. |
Welcome Guest, Not a member yet? Register Sign In |