Welcome Guest, Not a member yet? Register   Sign In
Using varialbes with more than one sql operation.
#1

[eluser]Nonox[/eluser]
Hi, I have a question about delete/updates/insert using $this->db->query. I tried to run something like this:

Code in the model script.
Code:
for ($i = 1; $i <= 10; $i++ )
    {
        $id = $this->input->post('field'.$i);
        $sql .= "DELETE FROM table WHERE id =".$this->db->escape($id).";";
    }
    $this->db->query($sql);

Return error:

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';DELETE FROM table WHERE id =2' at line 1

When I use pure PHP code this works, but I dont konw how I have to use this with CI.

Any help would be very much appreciated.
Thanks!


Messages In This Thread
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 06:35 AM
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 06:40 AM
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 06:46 AM
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 07:03 AM
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 07:21 AM
Using varialbes with more than one sql operation. - by El Forum - 10-20-2008, 09:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB