Welcome Guest, Not a member yet? Register   Sign In
query problem
#1

[eluser]dimis[/eluser]
I use this code
Code:
foreach ($lans as $lan)
        {
(".$lan['code'].",".$lan['name'].",".$id.")");
$sql = "replace into material_lan ( lan_id ,lan_text,material_id) values (?,?,?)";
            $this->db->query($sql,$lan['code'], $lan['name'],$id);

        }
and i have this error
Code:
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 '' at line 1

replace into material_lan ( lan_id ,lan_text,material_id) values ('en',
What is wrong ? I run this sql at sql manager lite and it is ok
#2

[eluser]Bramme[/eluser]
Try with an alternative syntax maybe...

Code:
$qry = "REPLACE INTO material_lan SET lan_id = "$value".."; // etc, you get the picture

It might be possible CodeIgniter messes up your syntax, not sure though.
#3

[eluser]Sumon[/eluser]
I think, you mixed up something.
You might expect either
Code:
$sql = "insert into material_lan ( lan_id ,lan_text,material_id) values ($lan['code'],$lan['name'],$id)";
or
Code:
$data = array(
               'lan_id' => $lan['code'] ,
               'lan_text' => $lan['name'] ,
               'material_id' => $id
            );
$this->db->insert('material_lan', $data);
#4

[eluser]dimis[/eluser]
replace is a statement of mysql (I thing only).
At my situation i thing it was buggy so I change it to update.
#5

[eluser]Michael Wales[/eluser]
You can use $this->output->enable_profiler(TRUE) to always see exactly what CI is sending to your database - great for catching little quirks where ActiveRecord isn't behaving as you would expect it to.




Theme © iAndrew 2016 - Forum software by © MyBB