Welcome Guest, Not a member yet? Register   Sign In
Having issue with updating database
#21

[eluser]InsiteFX[/eluser]
echo the value to see if it is being passed in.
Code:
function update_invite($id,$pid)
{
    echo 'pid = '.$pid;
    exit;

    $this->db->set('invited_pid',(int)$pid);
    $this->db->where('id',(int)$id);
    $this->db->update('invites');
    echo $this->db->last_query();
}

Also show your table maybe it is not correct!
#22

[eluser]Aken[/eluser]
Yeah, if they're showing the same query either 1) the last_query() is showing something else, or 2) the problem is elsewhere, because the query is exactly the same.
#23

[eluser]ZeroNine[/eluser]
@InsiteFX
I tried this already and $pidd is echoing the correct number.
I also tried running the same query into a brand new table and it will not update any table column with the number. It seems to be a problem only with this variable $pidd.

@Aken
The last_query() is identical. What I am doing is echoing both out and copy and pasting the query into phpmyadmin to check to see if the query is incorrect. The query does work if I do it this way.

So I believe the problem is elsewhere... but I have no idea what else it can be..

I have also went to the extent of doing this..

Code:
function update_invite($id,$pidd)
    {
        $this->db->set('invited_pid',(int)$pidd);
        $this->db->where('id',(int)$id);
        $this->db->update('invites');
        $query =  $this->db->last_query();
        $this->db->query($query);
        return $query;
    }

Then re delivering the query back to another model function through the controller..

Code:
$query = $this->invite_model->update_invite($inv_id,$reg_id);
$this->invite_model->do_query($query);


Code:
function do_query($query)
    {
        $this->db->query($query);
        echo $this->db->last_query();
    }

Even if I run the query three different ways, its still not working.


But if I do this
Code:
$query = $this->invite_model->update_invite($inv_id,'84');

This works.
#24

[eluser]ZeroNine[/eluser]
Ok, I finally figured it out.

To anybody else that may ever have the same issue. This is what I had to do.
Code:
$this->db->set('invited_pid',$pid,FALSE);

I had to prevent data from being escaped by adding FALSE to the third parameter.
So weird though that it didn't work with $data = array('invited_pid' => $pidd) either.. oh well.


Thanks guys for trying to help. I appreciate it! and sorry for such a noob problem.
#25

[eluser]Aken[/eluser]
What's the difference in the query that setting that does? If you're passing an integer, it shouldn't escape anything. There's nothing in those queries that needs escaping, so I'm curious what it changed that might actually help...




Theme © iAndrew 2016 - Forum software by © MyBB