Welcome Guest, Not a member yet? Register   Sign In
$this->db->update(),the third param, bug?
#1

[eluser]Unknown[/eluser]
I use this function like this :
$this->db->update($this->db->dbprefix('papers'),$this->paper, "paperid=".$this->paperid );
please note that the third param is a string ,as the user_guide says:
You'll notice the use of the $this->db->where() function, enabling you to set the WHERE clause. You can optionally pass this information directly into the update function as a string:
$this->db->update('mytable', $data, "id = 4");
and then the sql is wrong because the where clause looks likes where `paperid=1`. The right one should like where `paperid`=1 .
If i pass a assoc array to update
$this->db->update('mytable', $data, array('paperid'=>$this->paperid ));
the sql is right.

And my database is MySQL
#2

[eluser]CroNiX[/eluser]
Try putting a space before and after the =
Code:
"paperid = ".$this->paperid
#3

[eluser]Unknown[/eluser]
[quote author="CroNiX" date="1332215927"]Try putting a space before and after the =
Code:
"paperid = ".$this->paperid
[/quote]

It's ok now,thanks.
I should be more carefully.
In addition, i suggest that the user guide should emphasize this point.




Theme © iAndrew 2016 - Forum software by © MyBB